How do I label a plot as an object?
조회 수: 10 (최근 30일)
이전 댓글 표시
I have a very long script, and I want to include code to plat multiple graphs. But, I want to only see individual plots after I 'call' it from the command window. How do I do this?
Initially, I drew subplots, but they always are plotted when I run the script, even if I put a ';' at the end of the lines of code.
I tried:
PLOT1 = plot(time, temp);
xlabel({'Time','(minutes)'});
ylabel({'Temperature','(°C)'});
But this didnt work. I would also like to be able to label the axis as shown above.
Thanks!
댓글 수: 0
답변 (1개)
Thorsten
2016년 7월 20일
편집: Thorsten
2016년 7월 20일
You can add a pause after each plot
plot(time, temp)
xlabel({'Time','(minutes)'});
ylabel({'Temperature','(°C)'});
pause
plot(time2, temp2)
xlabel({'Time','(minutes)'});
ylabel({'Temperature','(°C)'});
Then you have to press a key to see the next plot.
Your label commands are fine.
The ; after plot just suppresses the output of the handle PLOT1, but not the plot.
If you don't want the plot, just remove the line, or put it in comment, or use something like
do_plot = true; % true or false
if do_plot
plot(time, temp)
end
if do_plot
plot(time2, temp2)
end
You could also overwrite the plot function with clf, e.g., in case you do not want any plots. Then you do not have to surround your plot commands with "if do_plot... end"; but this is kind of a hack, I guess:
if do_plot
clear plot % restore original plot command
else
plot = @(varargin) clf;
end
plot(time, temp)
plot(time2, temp2)
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Axis Labels에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!