How do I create a function for returning a figure?
21 views (last 30 days)
Show older comments
Monika Szymanczak
on 29 Nov 2021
Commented: Katrin Silke Wilhelm
on 14 May 2022
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
0 Comments
Accepted Answer
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
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.
More Answers (0)
See Also
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!