필터 지우기
필터 지우기

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

조회 수: 1 (최근 30일)
Natalia Wong
Natalia Wong 2015년 11월 22일
답변: Image Analyst 2015년 11월 22일
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