Hello,
I am writing a script that produces an array, vq, every iteration through a loop. I am trying to save each version of vq so I can compare each vq row by row later on. I suppose storing each vq as a column in a matrix would be ideal since each vq is the same length. This is my code:
for m=B1(1:end,:)
for n = B2(1:end,:)
for p=1:length(B1)
H=find(time_dec > m(p) & time_dec < n(p));
[Alt,index]=unique(Alt(H));
temp=Temp(H);
xq=30.5:17.5:2000;
vq=interp1(Alt,temp(index),xq)';
end
end
end
Any suggestions?
Thank you very much.

댓글 수: 5

Stephen23
Stephen23 2019년 7월 1일
What sizes are B1 and B2 ?
Olivia Booth-Howe
Olivia Booth-Howe 2019년 7월 1일
B1 and B2 chance size every iteration but are always the same size as each other. They are vectors of length 2, 3, 4, 5, or 6.
Olivia Booth-Howe
Olivia Booth-Howe 2019년 7월 1일
The code works fine to produce the vq I want, I just need to save it as a matrix and simply putting vq(p) (how I would usually do it) doesn't work here. Thanks again!
"Doesn't work" is not useful to describe a problem.
This looks strange:
for m=B1(1:end,:)
"They are vectors of length 2, 3, 4, 5, or 6." - please post their size(). It matters, if they are row or column vectors.
Olivia Booth-Howe
Olivia Booth-Howe 2019년 7월 1일
Solved it! Thanks anyway.

댓글을 달려면 로그인하십시오.

 채택된 답변

KALYAN ACHARJYA
KALYAN ACHARJYA 2019년 7월 1일
편집: KALYAN ACHARJYA 2019년 7월 1일

2 개 추천

-The code works fine to produce the vq I want, I just need to save it as a matrix and simply putting vq(p)-
You can save it as structure cell array, as I have no idea of the length of vq would be. Hence I have choosen different variable I.
vq={}
l=1;
for
.......
vq{l}=
l=l+1
end
or
If the length is p, then you can use vq{p}=.. too. On such case remove l.
vq={}
for
.......
vq{p}=
end

댓글 수: 3

Olivia Booth-Howe
Olivia Booth-Howe 2019년 7월 1일
That is exactly what I needed, thank you so much! I really appreciate it.
KALYAN ACHARJYA
KALYAN ACHARJYA 2019년 7월 1일
Always welcome @Olivia
Jan
Jan 2019년 7월 2일
+1. Exactly.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

질문:

2019년 7월 1일

댓글:

Jan
2019년 7월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by