How do I create a function for returning a figure?

I have to create a function that returns a figure consisting of an average (as it is a singular output noted in the comment beside C I am not sure how to have MATLAB return the figure) Moreover, I'm not sure what would be a suitable X axis label (but that's not really important right now) Moreover, I'm not sure what would be a suitable x axis in general as it is a singular figure
Additionally, any advice on how I could have it return the figure in either red or orange?
Thank you

 채택된 답변

Dyuman Joshi
Dyuman Joshi 2021년 11월 29일
Example (replace data and labels accordingly)
function y
%xdata
x=0:0.1:50;
%ydata
y=sin(x);
figure(1) %initiate a figure
plot(x,y,'r') %use 'o' for orange
xlabel('Time');
ylabel('Sine curve');
title('Sin curve graph')
end

댓글 수: 2

thank you!
I've tried to build a function as you described. The problem is only the data (plotted) shows in the main program. The changed axis, title and ledgend are missing. Even when I create a figure, to wich i assign the changes and give to the main program as a variable.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Annotations에 대해 자세히 알아보기

제품

릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by