Azzera filtri
Azzera filtri

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

1 visualizzazione (ultimi 30 giorni)
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

Risposta accettata

Image Analyst
Image Analyst il 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;

Più risposte (0)

Categorie

Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange

Tag

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by