How to effectively plot semi continuous graph
1 次查看(过去 30 天)
显示 更早的评论
Dear Matlab Code The objective was to have a plot as below
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/165825/image.jpeg)
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.
0 个评论
采纳的回答
Star Strider
2017-7-6
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Calendar 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!