![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/179938/image.png)
Merge number of curves
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Aleksandr Bashkatov
il 10 Mar 2018
Commentato: Star Strider
il 11 Mar 2018
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!
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/171139/image.jpeg)
0 Commenti
Risposta accettata
Star Strider
il 10 Mar 2018
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/179938/image.png)
Experiment to get the result you want.
2 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Annotations in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!