How do you crete a function file?

1 vue (au cours des 30 derniers jours)
Mark Davies
Mark Davies le 13 Déc 2019
Modifié(e) : Dyuman Joshi le 20 Mar 2023
I need to create a function file that contains the commands to plot ? = sin ? and ? = sin2 ? on the same graph, I need to use the following expression to define the range of x in the function x=0:pi/A:2*pi. I then need to test the function using different values of A. Does this make sense?

Réponse acceptée

Dyuman Joshi
Dyuman Joshi le 14 Déc 2019
Modifié(e) : Dyuman Joshi le 20 Mar 2023
Write the code, for e.g.
function y=graphplot(A)
x=0:pi/A:2*pi;
plot(x, sin(x))
hold on
plot(x, sin(2*x))
hold off
end
Call the function in the command window with an arbitary value of 'A'
graphplot(100) and plotted graphs will come as output. Try to give large values of A to ensure smooth curvesa and make sure the file is saved as the same name as the function.
  1 commentaire
Mark Davies
Mark Davies le 19 Déc 2019
Thank you :)

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Graph and Network Algorithms dans Help Center et File Exchange

Produits


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by