A function that outputs multiple plots? Part 2

2 ビュー (過去 30 日間)
alpedhuez
alpedhuez 2020 年 8 月 13 日
コメント済み: alpedhuez 2020 年 8 月 17 日
In a previous question, one learned a function without output and output plots.
I now want to write a function that output some numbers and multiple plots. I have tried
figure(1);plot(x,y)
but did not work. What can be done?

回答 (1 件)

Adam Danz
Adam Danz 2020 年 8 月 13 日
編集済み: Adam Danz 2020 年 8 月 13 日
If you want to set the figure number,
h = figure();
% or
h = figure(5);
plotoutput(__,h) % fill in your other inputs
function plotoutput(__,figureHandle) % fill in your other inputs
% Test input
assert(isscalar(figureHandle) && isa(figureHandle,'matlab.ui.Figure'), ...
'figureHandle must be an existing figure handle.')
ax = axes(figureHandle);
plot(ax, ___)
end
--or--
n = 5;
function plotoutput(__, figureNumber)
% Test input
assert(isscalar(figureNumber) && mod(figureNumber,1)==0 && ...
figureNumber>0 && figureNumber < 2147483646, ...
'figureNumber must be a scalar integer from 1 to 2147483646')
h = figure(figureNumber);
ax = axes(h);
plot(ax, ___)
end
  3 件のコメント
Adam Danz
Adam Danz 2020 年 8 月 17 日
Has your problem been solved?
alpedhuez
alpedhuez 2020 年 8 月 17 日
Have been working on it.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by