store values from a loop in a vector
Mostrar comentarios más antiguos
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?
Respuestas (1)
Azzi Abdelmalek
el 5 de En. de 2014
0 votos
Just creat a matrix nxm
6 comentarios
anna
el 5 de En. de 2014
Editada: Azzi Abdelmalek
el 5 de En. de 2014
Azzi Abdelmalek
el 5 de En. de 2014
Maybe you want to change vecC(k,:)=cosd(ratio) to
vecC(k,i)=cosd(ratio)
anna
el 5 de En. de 2014
Azzi Abdelmalek
el 5 de En. de 2014
But you have to read the data from each file, this does not appear in your code
anna
el 6 de En. de 2014
Azzi Abdelmalek
el 6 de En. de 2014
Editada: Azzi Abdelmalek
el 6 de En. de 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
Categorías
Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!