Plotting 3 unequal vectors
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
jchris14
am 22 Aug. 2016
Kommentiert: Star Strider
am 22 Aug. 2016
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
0 Kommentare
Akzeptierte Antwort
Star Strider
am 22 Aug. 2016
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 Kommentare
Star Strider
am 22 Aug. 2016
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.)
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!