Merge number of curves
1 次查看(过去 30 天)
显示 更早的评论
Dear MathWorks community,
Thanks for your time in advance.
I have a number of curves (for example 4) with the same Y range, but different range along X axis.
Problem: I would like to arrange it one after another into one Figure. It means that X axis should be divided into four parts and each parts should have its own x range. All of the parts should be at the same X axis. Just to be more clear: It should looks like one Figure with one Y axis and four X axis that follow each other.
In the attachments you can see an idea how it should works (more or less).
If you have any idea, I would be really happy. Many thanks!
0 个评论
采纳的回答
Star Strider
2018-3-10
Try this:
t1 = linspace(0, 6, 500); % Create Independent Variable Data
t2 = linspace(0, 11, 500);
t3 = linspace(0, 16, 500);
s1 = sin(25*pi*t1) .* exp(-0.5*t1); % Create Dependent Variable Data
s2 = sin(15*pi*t2) .* exp(-0.3*t2);
s3 = sin(10*pi*t3) .* exp(-0.2*t3);
xtv = [max(t1) max(t2) max(t3)]; % Define Section Limits
figure(1)
plot(t1, s1) % Plot Signal 1
hold on
plot(t2+xtv(1), s2) % Plot Signal 2
plot(t3+xtv(1)+xtv(2), s3) % Plot Signal 3
YL = ylim;
plot(cumsum([xtv(1:2); xtv(1:2)],2), YL(:)*[1 1], '--k', 'LineWidth',1) % Plot Vertical Separation Lines
hold off
set(gca, 'XLim',[0 sum(xtv)]); % Define X-Axis Limits
xtix = [(0:xtv(1)-1) (0:xtv(2)-1) (0:xtv(3))]; % Define Tick Labels
set(gca, 'XTick',linspace(0, 1, numel(xtix))*(sum(xtv)), 'XTickLabel',xtix, 'FontSize',8) % Plot Tick Labels
Experiment to get the result you want.
更多回答(0 个)
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!