Azzera filtri
Azzera filtri

How to effectively plot semi continuous graph

1 visualizzazione (ultimi 30 giorni)
Dear Matlab Code The objective was to have a plot as below
At the moment, I am using a rather ineffecient approach, such as,
Xaxis = [273.5 275.5 277.5 279.5 281.5 283.5 303.5 305.5 307.5 315.5 317.5 319.5];
Yaxis = [0.61202 1.62647 1.37831 2.74613 2.24585 0.49887 0.61202 0.73511 2.2399 1.62647 1.99175 4.61222];
subplot(2,1,1);
plot (Xaxis (1,1:6), Yaxis (1,1:6), '--mo');
hold on
plot (Xaxis (1,7:9), Yaxis (1,7:9), '--mo');
hold on
plot (Xaxis (1,10:12), Yaxis (1,10:12), '--mo');
May I know any other smart alternative to the above line?
Thanks in advance for the time.

Risposta accettata

Star Strider
Star Strider il 6 Lug 2017
I cannot say this is better, but it is different, and does the vector splitting on its own:
Xaxis = [273.5 275.5 277.5 279.5 281.5 283.5 303.5 305.5 307.5 315.5 317.5 319.5];
Yaxis = [0.61202 1.62647 1.37831 2.74613 2.24585 0.49887 0.61202 0.73511 2.2399 1.62647 1.99175 4.61222];
Xsplit = diff([0 find(diff(Xaxis)>2) length(Xaxis)]); % Find Discontinuities & Create Lengths Vector
Xc = mat2cell(Xaxis, 1, Xsplit); % Split ‘Xaxis’
Yc = mat2cell(Yaxis, 1, Xsplit); % Split ‘Yaxis’
figure(1)
plot(Xc{1}, Yc{1}, '--mo', Xc{2}, Yc{2}, '--mo', Xc{3}, Yc{3}, '--mo')
  6 Commenti
balandong
balandong il 7 Lug 2017
Dear Star Thanks for the detailed explanation. Really appreciate it.

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by