How do I create a function for returning a figure?

21 views (last 30 days)
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

Accepted Answer

Dyuman Joshi
Dyuman Joshi on 29 Nov 2021
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 Comments
Katrin Silke Wilhelm
Katrin Silke Wilhelm on 14 May 2022
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.

Sign in to comment.

More Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!