How do I create a function for returning a figure?

20 vues (au cours des 30 derniers jours)
Monika Szymanczak
Monika Szymanczak le 29 Nov 2021
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

Réponse acceptée

Dyuman Joshi
Dyuman Joshi le 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 commentaires
Monika Szymanczak
Monika Szymanczak le 29 Nov 2021
thank you!
Katrin Silke Wilhelm
Katrin Silke Wilhelm le 14 Mai 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.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by