Return figure handle from a function
Mostrar comentarios más antiguos
I have a function that plots two variables and returns the plot handle. This function is currently returning a line object instead of a figure. How can I force MATLAB to return a figure?
%%Plotting function
function li = liner(a,b)
li = plot(a,b);
end
%% From prompt >> a =0:1:10; >> c = liner(a, 2*a); >> class(c)
ans =
'matlab.graphics.chart.primitive.Line'
Respuesta aceptada
Más respuestas (1)
Fangjun Jiang
el 12 de Jul. de 2017
Try this?
%%Plotting function
function li = liner(a,b)
li = figure;
plot(a,b);
end
Categorías
Más información sobre Graphics Objects en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!