Return figure handle from a function
이전 댓글 표시
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'
채택된 답변
추가 답변 (1개)
Fangjun Jiang
2017년 7월 12일
Try this?
%%Plotting function
function li = liner(a,b)
li = figure;
plot(a,b);
end
카테고리
도움말 센터 및 File Exchange에서 Graphics Objects에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!