store values from a loop in a vector
이전 댓글 표시
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?
답변 (1개)
Azzi Abdelmalek
2014년 1월 5일
0 개 추천
Just creat a matrix nxm
댓글 수: 6
anna
2014년 1월 5일
편집: Azzi Abdelmalek
2014년 1월 5일
Azzi Abdelmalek
2014년 1월 5일
Maybe you want to change vecC(k,:)=cosd(ratio) to
vecC(k,i)=cosd(ratio)
anna
2014년 1월 5일
Azzi Abdelmalek
2014년 1월 5일
But you have to read the data from each file, this does not appear in your code
anna
2014년 1월 6일
Azzi Abdelmalek
2014년 1월 6일
편집: Azzi Abdelmalek
2014년 1월 6일
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
카테고리
도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!