I have a time range (t) going from 1 to 20, and a random collection of data of 20 points (y). I need to have y(1,:) for t(1,:), y(2,:) for t(2,:) and so on. This is what I wrote:
for t=1:1:20.0
a = y(1,:) : y(20,:)
end
But all this executes is the just one value of y (the first or the last, I can't tell because they are the same number). What should I correct?

댓글 수: 2

Azzi Abdelmalek
Azzi Abdelmalek 2015년 6월 7일
Your question is not clear
Hiskiel Stephanus
Hiskiel Stephanus 2015년 6월 9일
편집: Hiskiel Stephanus 2015년 6월 9일
I am assuming you are trying to assign values to an "a" matrix. Try making "a" a dynamic array by saying
a(1,t) = y(1,:) : y(20,:)

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

 채택된 답변

Walter Roberson
Walter Roberson 2015년 6월 7일

0 개 추천

for t = 1:20
a = y(t,:);
fprintf('y value #%t was %g\n', t, a); %example of using the data
end

댓글 수: 1

Prakriti Sardana
Prakriti Sardana 2015년 6월 7일
편집: Prakriti Sardana 2015년 6월 7일
Hm, thank you very much. This works well for me.
PS: If I happen to use a part of this code in my summer project, I would credit you. :p Hehe.

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

추가 답변 (0개)

카테고리

도움말 센터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!

Translated by