See stackedplot function https://in.mathworks.com/help/matlab/ref/stackedplot.html
Draw multi graphs in one figure
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
How to draw multi plots with same x axis and different ranged y axis in a same figure? (See the x axis and y axis values written in the image attached) . ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1417739/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1417739/image.jpeg)
clc;
close all;
t=0:0.000001:0.1;
x=sin(100*t);
y=cos(100*t);
plot(t,x);
hold on
plot(t,y);
Risposta accettata
Ergin Sezgin
il 23 Giu 2023
Hi Reji,
However, If you need something similar to what you draw in your attachment, you can trick figure to add some offset to one of your arrays and change y axes labels to appropriate strings. Check the following code block:
clc
clear
close all;
t = 0:0.000001:0.1;
x = sin(100*t);
y = cos(100*t);
y = y + 3; % Offset
figure
plot(t,x);
hold on
grid on
plot(t,y);
yTickLabels = string([-1 -0.5 0 0.5 1 0 -1 -0.5 0 0.5 1]);
set(gca, 'yticklabel', yTickLabels)
Good luck
Più risposte (1)
Aakash
il 23 Giu 2023
You can achieve the desired outcome using subplot function as below:
t=0:0.000001:0.1;
x=sin(100*t);
y=cos(100*t);
figure;
subplot(2, 1, 1); % First subplot
plot(t, x);
ylim([-1 1]);
title('Plot 1');
subplot(2, 1, 2); % First subplot
plot(t, y);
ylim([-1 1]);
title('Plot 2');
Vedere anche
Categorie
Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!