Answered
Load different mat files using for loop
Assuming that each mat file contains exactly one variable of unknown name, then try this: D = 'D:\ABIDEdataset\Outputs\dparsf\n...

5 years ago | 0

| accepted

Answered
cell indexing, extracting rectangular subset
The simplest (and usually quite efficient) approach is to use a comma-separated list to create one cell array: tmp = vertcat(to...

5 years ago | 0

| accepted

Answered
Computation on arrays using loops
Y = [2.659717,2.656496,2.656496,2.656173,2.662294,2.661328,2.660039,2.620416,2.614295,2.606242,2.600765,2.600443,2.590779,2.5917...

5 years ago | 1

| accepted

Answered
How to load all the data in one folder
"I am wonder why it happened." Because you always load exactly the same file data (note the indexing you used): filename{1,1} ...

5 years ago | 1

Answered
Tabulating a Function with exponential values and using fprintf
The loop is not required. By vectorizing the function you can simplify your code. https://www.mathworks.com/help/matlab/matlab_...

5 years ago | 0

Answered
Why do I get "0x301 empty double matrix" when reading a cell array with data in it?
"Why do I get "0x301 empty double matrix" when reading a cell array with data in it?" Because you specified two header lines, b...

5 years ago | 0

| accepted

Answered
Function handles and passing parameters to ode solver
Like this: c_h = ... some value; c_v = ... some value; ... all the others variables myTorque = ... some value; % Now define...

5 years ago | 0

| accepted

Answered
Write matrix or array without overwriting
You are mixing up two different approaches to adding data in a loop: concatenation and indexing. Just pick one, e.g.: A = [A;te...

5 years ago | 0

| accepted

Answered
How to create a vector, knowing start, increment and number of values.
B = 6.333954480229592e-06; I = 3.906250000000000e-05; N = 537600; V = B + I*(0:N-1);

5 years ago | 0

| accepted

Answered
Appending data in multiple structures using a loop
D = 'absolute/relative path to where the files are saved'; S = dir(fullfile(D,'*.mat')); N = numel(S); for k = 1:N F = f...

5 years ago | 0

Answered
Cell Array always includes a period as its first value
"So, why does fileinfo.name return those first 3 columns, and how can I get rid of them?" Because DIR returns exactly what the ...

5 years ago | 0

| accepted

Answered
How to use index for structure within for loop?
Using numbered variable names is a sign that you are doing something wrong. The simple and efficient approach is to use one non...

5 years ago | 0

Answered
Why \n or newline doesn't work ?
"Do someone know why ?" The documentation states "For character array inputs, strcat removes trailing ASCII white-space charact...

5 years ago | 1

| accepted

Answered
Access multiple structure fields and put them in a new structure or vector
No, what you are asking for is not possible. This syntax: dataArray{1,2:10} creates a comma-separated list of separate arrays,...

5 years ago | 0

| accepted

Answered
Append to vector of different sizes in for loop
Simpler: S = load('test_file.mat') fun = @(b,e)S.TimeSeries_short(b:e); out = arrayfun(fun,S.ipts(1:2:end),S.ipts(2:2:end),'u...

5 years ago | 0

| accepted

Answered
i have loop and i need to Create a table for each loop
Use indexing rather than numbering the variables: N = the number of tables that you want C = cell(1,N); for k = 1:N C{k} ...

5 years ago | 0

| accepted

Answered
how to append matrix in a loop
s1 = [1,0,1,1,0]; s2 = [2,4,3,1,2]; v = repelem(s1,s2)

5 years ago | 0

Answered
How to combine to identical 'for' loops with sequential varying variables ?
Numbering variables like that is completely the wrong approach and should be avoided. One better approach is to use a container...

5 years ago | 0

| accepted

Answered
for loop with vectors having different sizes
a = {[1,2],[3,4,5]}; p = {[6,7],[8,9,10,11]}; c = 'trial'; for k1 = 1:numel(a) for k2 = 1:numel(p) s = sprintf(...

5 years ago | 0

Answered
using natsortfiles to import csv files correctly
Taking a guess that you actually want to match the last integer, not just the last digit: S = natsortfiles(S,'\d+^$'); % alphan...

5 years ago | 0

Answered
Read multiple .CSV files with csvread using a loop
V = 0:4; N = numel(V); C = cell(1,N); for k = 1:N F = sprintf('droplet.%d.csv',V(k)); C{k} = readmatrix(F,'NumHeade...

5 years ago | 0

| accepted

Answered
Convert cell array to matrix with two columns and sort rows by first column value
More robust and more efficient than using cell2mat: M = vertcat(Cell_x{:}); M = sortrows(M,1)

5 years ago | 0

| accepted

Answered
evaluate function handle (determine the value of function handle using my code
Defining lots and lots of function handles is not an efficient approach. One function is much simpler: myfun(30) function hf...

5 years ago | 0

| accepted

Answered
Search/Find sub strings in a string
This matches abbreviations followed by one digit (thus avoiding the Ra/Rag matching problem): C = {'Ra','Bt','Rag','Rg','Vm','S...

5 years ago | 1

Answered
Modify Repmat function to concatenate array
V = [0,1,2,3,4]; n = 3; X = [1,10*(1:n-1)]; Z = kron(X,V)

5 years ago | 0

| accepted

Answered
How to display the Index of a matrix to other corresponding matrices
A = [8,3,5;2,4,6;9,3,4] B = [4,11,5;9,3,2;4,8,1] C = [11,40,3;10,7,5;11,3,60] [v,x] = min(A(:)); B(x) C(x) Or without resh...

5 years ago | 0

| accepted

Answered
How to create a symetric matrix with a vector?
A general solution using indexing: V = [1,2,3,4,5] X = 1:numel(V); M = V(max(X,X.'))

5 years ago | 1

| accepted

Answered
Undefined function 'eq' for input arguments of type 'cell'. Undefined function 'gt' for input arguments of type 'cell'
@ASHU DAYAL CHAURASIYA: the error message clearly tells us what the cause of the error is: one (or both) of the arrays is actual...

5 years ago | 0

Answered
Set default value if no function input given
You did not count the input t when using nargin. You can include the number of inputs before varargin in the logical comparisons...

5 years ago | 0

| accepted

Load more