Filter löschen
Filter löschen

can i have 3 different graphs in a same m-file?

1 Ansicht (letzte 30 Tage)
Natalia Wong
Natalia Wong am 22 Nov. 2015
Beantwortet: Image Analyst am 22 Nov. 2015
Hi I have plotted 3 different graphs in a single m-file but I can only view one graph. How to make all 3graphs pop out simultaneously. And, if i want to plot a red asterisk at let's say when the y-coordinate is more than 20, how do i do it? 'r*' >20? I tried but can't
Thanks and Im new to MATLAB

Akzeptierte Antwort

Image Analyst
Image Analyst am 22 Nov. 2015
Use subplot, and set elements you don't want to display to nan.
Try this:
y1 = randi(50, 1, 20);
subplot(3,1,1);
plot(y1, 'b-');
hold on;
yBig = y1;
yBig(y1 <= 20) = nan;
plot(yBig, 'r*', 'LineWidth', 2, 'MarkerSize', 9);
grid on;
y2 = randi(50, 1, 20);
subplot(3,1,2);
plot(y2, 'b-');
hold on;
yBig = y2;
yBig(y2 <= 20) = nan;
plot(yBig, 'r*', 'LineWidth', 2, 'MarkerSize', 9);
grid on;
y3 = randi(50, 1, 20);
subplot(3,1,3);
plot(y3, 'b-');
hold on;
yBig = y3;
yBig(y3 <= 20) = nan;
plot(yBig, 'r*', 'LineWidth', 2, 'MarkerSize', 9);
grid on;

Weitere Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Tags

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by