A function that outputs multiple plots? Part 2

1 Ansicht (letzte 30 Tage)
alpedhuez
alpedhuez am 13 Aug. 2020
Kommentiert: alpedhuez am 17 Aug. 2020
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?

Antworten (1)

Adam Danz
Adam Danz am 13 Aug. 2020
Bearbeitet: Adam Danz am 13 Aug. 2020
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 Kommentare
Adam Danz
Adam Danz am 17 Aug. 2020
Has your problem been solved?
alpedhuez
alpedhuez am 17 Aug. 2020
Have been working on it.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by