Is it possible to plot multiple functions in one plot?
조회 수: 648 (최근 30일)
이전 댓글 표시
What specific matlab commands are needed to do this? For example, I am trying to place three functions that can fit into one figure with the following functions: y=x^2 y=-5x+2 y=4
댓글 수: 0
답변 (1개)
Star Strider
2015년 2월 14일
There are likely several options. If you mean on one set of axes, the hold function is likely best. If you want each on separate axes in the same figure, use subplot.
Illustrating:
x = linspace(-5, 5);
y1=x.^2;
y2=-5*x+2 ;
y3=4*ones(size(x));
figure(1)
plot(x, y1)
hold on
plot(x, y2)
plot(x, y3)
hold off
grid
figure(2)
subplot(3,1,1)
plot(x, y1)
grid
subplot(3,1,2)
plot(x, y2)
grid
subplot(3,1,3)
plot(x, y3)
grid
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Subplots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!