필터 지우기
필터 지우기

Plotting 3 unequal vectors

조회 수: 1 (최근 30일)
jchris14
jchris14 2016년 8월 22일
댓글: Star Strider 2016년 8월 22일
Hi guys,
having a little trouble plotting this. I want to plot timeMat in the x axis and other vectors (GrayValScan,StoreData) in the y axis. Note: GrayValScan and StoreData are both different dimensions from each other as well.
timeMat= abs(-860:0);
i=3;
n=107;
while n<=107
figure
hold on
plot(timeMat,GrayValScan)
plot(timeMat,storeData(:,i))
hold off
i= i+1;
end
I tried doing this based on another answer and repeat it for the other vector. Nothing worked.
maxLength = max(timeMat);
GrayValScan(length(timeMat)+1:maxLength) = 0;
Any suggestion? Thanks in advance

채택된 답변

Star Strider
Star Strider 2016년 8월 22일
I would use the linspace function:
GVStimeMat = linspace(-860, 0, length(GrayValScan));
SDtimeMat = linspace(-860, 0, size(storeData,1));
i=3;
n=107;
while n<=107
figure
hold on
plot(GVStimeMat,GrayValScan)
plot(SDtimeMat,storeData(:,i))
hold off
i= i+1;
end
NOTE I don’t have your data, so this is UNTESTED CODE. It should work.
  댓글 수: 4
jchris14
jchris14 2016년 8월 22일
Thank you for the explanation. I didn't realize that the n value didn't do anything in the loop. I took it out and dealt with just "I".
As for the dimension mismatch error I was getting, it was conditional error. I used a <= instead of just <
Star Strider
Star Strider 2016년 8월 22일
My pleasure.
If you know in advance the limits ‘i’ should have, you can use a for loop. That might be more efficient, since it incorporates the incrementing of ‘i’ and would eliminate the separate counter increment assignment. (A while loop is best if you’re incrementing and testing a value calculated within a loop.)

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by