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

1 次查看(过去 30 天)
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

采纳的回答

Image Analyst
Image Analyst 2015-11-22
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;

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by