Answered
Reading in file as cell array in a two dimensional [1x1] structure
Use the CollectOutput option: opt = {'CollectOutput',true}; fmt = '%s%s%s%s%s%s%s%s%s%s'; C = textscan(fid,fmt,opt{:}); C = ...

8 years ago | 0

| accepted

Answered
specified numbers of random permutation of a vector
Where V is your vector: idx = randperm(n); V(idx(1:100))

8 years ago | 0

Answered
I have an idea that I want to write in MATLAB language
"Is there a way that makes MATLAB finds the x that crossponds to fh and fL ... ?" You could use indexing: >> M = [8,9;10,11;8,...

8 years ago | 0

| accepted

Answered
How to count NaN elements in n dimentional matrix, using counter in loop?
Where A is your array: cnt = 0; for k = 1:numel(A) cnt = cnt+isnan(A(k)); end

8 years ago | 0

Answered
compute the mean of matrices with different dimensions
Z = nan(2370,512,3); Z(:,1:512,1) = A; Z(:,1:512,2) = B; Z(:,1:256,3) = C; mean(Z,3)

8 years ago | 0

| accepted

Answered
Try to make a function for deflection and is just dosen`t want to work.
Simpler: >> W = 8500; % max load (N) >> E = 42000; % elastic modulus (N/mm^2) >> I = 10e6; % ??? (mm^4) >> Dfun = @(L) (W*...

8 years ago | 1

| accepted

Answered
Creating a matrix showing the binary units of the numberline from 0 to (2**n)-1
a = 0:7; b = dec2bin(a)-'0' % ^^^^ if you want to get a numeric array

8 years ago | 0

| accepted

Answered
Find and reduce a numeric array with identical columns
>> [~,X,Y] = unique(tmp(:,[1,3]),'rows'); >> out = tmp(X,:); >> out(:,2) = accumarray(Y,tmp(:,2),[],@sum) out = 119.0000...

8 years ago | 0

| accepted

Answered
Need some help with a while loop
"however, the code seems to loop infinitely many times I guess. I have no clue why? Is there anything wrong with the code??" Yo...

8 years ago | 0

| accepted

Answered
Creating logical arrays based on condition
>> a = [0.5,0.7,0.9]; >> b = [0.3,0.8,0.7]; >> c = [0,1,2]; >> f = c; >> f(a<=b) = -1 f = 0 -1 2

8 years ago | 0

Answered
if in a row i am having 6 numerical values of large number i want convert into binary form of length 10 bits
>> V = [234,567,123,456,900,190]; >> M = dec2bin(V(:),10) M = 0011101010 1000110111 0001111011 0111001000 1110000100 001...

8 years ago | 1

| accepted

Answered
permuting one matrix w.r.t. another matrix
Use sub2ind, e.g.: >> a = [1,2,3;4,5,6;7,8,9;10,11,12] a = 1 2 3 4 5 6 7 8 9 10 11 12...

8 years ago | 0

| accepted

Answered
How to get all possible arrays by randomizing in each cells with four items (1x6 array)
A simple solution with ndgrid: >> x = 99; >> y = 188; >> z = 277; >> C = cell(1,6); >> [C{:}] = ndgrid([0,x,y,z]); >> C = ...

8 years ago | 1

Answered
Sort characters w/ number in a field of struct array
You could download natsortfiles, which now directly sorts the DIR output structure: S = dir(..); S = natsortfiles(S); % alphan...

8 years ago | 1

Answered
Combining cells into a single cell
Simpler: out = cat(3,z{:}) https://www.mathworks.com/help/matlab/matlab_prog/comma-separated-lists.html https://www.mathworks...

8 years ago | 1

Answered
Array not returning any value when passed through a nested function
Inside your nested function you allocate to U, but not to u. MATLAB is case sensitive! Inside the nested function you allocate ...

8 years ago | 0

Answered
print output in table format and print the max value
% Density, kg/m^3 rho = 210; T = 2.5; % Volume , m^3 V = 0.018457; % Diameters, m D = [0.05 0.10 0.15 0.20]; % Height, ...

8 years ago | 1

| accepted

Answered
copy 1 part of text in complex text file
This copies the exact text from the input file into the output file, starting from "output final hypocenters" until the end of t...

8 years ago | 1

| accepted

Answered
The error using "load" and "fgets" codes in MATLAB 2013a?
Use fgetl, not fgets: Read_Pr = load(fgetl(fid)) % ^ As its help clearly states, fgets includes the newlines...

8 years ago | 0

| accepted

Answered
How can i use ' character in a string
How to create character arrays (including single quotes) is described in the documentation: https://www.mathworks.com/help/matl...

8 years ago | 1

| accepted

Answered
Mesh 3-D plot axes position
Set the axes' Projection, CameraPosition and CameraUpVector properties: https://www.mathworks.com/help/matlab/ref/matlab.graphi...

8 years ago | 0

Answered
How can I keep values of an array random.
Use randperm to generate a random permutation of that vector: >> T = [0,1,2,7,71,158,187]; >> A = T(randperm(numel(T))) A = ...

8 years ago | 0

Answered
convert categorical to numeric
https://www.mathworks.com/matlabcentral/answers/394456-how-to-convert-from-categorical-to-double https://www.mathworks.com/matl...

8 years ago | 0

| accepted

Answered
How to load a file in a function
"'tubeguide' is the function name, and 'hamm_and_city' is the file I'm attempting to load, but currently, nothing loads into the...

8 years ago | 0

| accepted

Answered
How to apply a equation to specific rows in a matrix
X = m(:,1)<=10; Y = 10<m(:,1) & m(:,1)<=25; Z = nan(size(m,1),1); Z(X) = m(X,2).^2 .* 3.*n(X,2).^2; Z(Y) = m(Y,2).*2; Givin...

8 years ago | 0

| accepted

Answered
How to loop through all files in subfolders in a main folder?
https://www.mathworks.com/help/matlab/import_export/process-a-sequence-of-files.html D = 'full path to the main folder'; S = d...

8 years ago | 6

| accepted

Answered
Error while evaluating UIControl Callback.
As its help clearly explains, run will run a script, but it will not run a function (e.g. a GUI main file). https://www.mathwor...

8 years ago | 0

| accepted

Answered
Divide a cell arrays with a part of another cell array?
Division is not defined for container classes (like cell arrays), it is only defined for numeric types. Which means that you wil...

8 years ago | 0

| accepted

Answered
Matlab coder giving issue with 'textscan'
Basically you will have to read the data as characters, and then convert to numeric. Probably the easiest way to do this is to u...

8 years ago | 3

| accepted

Answered
loop to extract set of rows for .txt file
hdr = {}; num = {}; [fid,msg] = fopen('text.txt','rt'); % Ignore first five lines: for k = 1:5 fgetl(fid); end % Read...

8 years ago | 1

| accepted

Load more