store values from a loop in a vector

1 view (last 30 days)
anna
anna on 5 Jan 2014
Edited: Azzi Abdelmalek on 6 Jan 2014
Hi,
I have a for loop that calculates "n" values for each file. Meaning n values are calculated for file 1 and then a different n values are calculated for file 2 etc.. I just want to form arrays that contains the ith value from each of the n value. Meaning [1a, 1b,...] then [2a, 2b,...]...[na, nb,...] How would I do that?

Answers (1)

Azzi Abdelmalek
Azzi Abdelmalek on 5 Jan 2014
Just creat a matrix nxm
  6 Comments
anna
anna on 6 Jan 2014
yes, sorry, i shortened it but there is a part where I read each file with the loop with k indices. xLfiles=dir(myFilePattern)
Azzi Abdelmalek
Azzi Abdelmalek on 6 Jan 2014
Edited: Azzi Abdelmalek on 6 Jan 2014
for k = 1:length(xlFiles)
%read data from files
y=diff(data(:,14)');
x=diff(data(:,17)');
ratio = atand(y./x);
vecC(k,:)=cosd(ratio)
end

Sign in to comment.

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!