Effacer les filtres
Effacer les filtres

Self-written function does not work when changing input names

2 vues (au cours des 30 derniers jours)
Zoe
Zoe le 21 Mai 2018
Commenté : Ameer Hamza le 21 Mai 2018
I wrote a function shown below. When I want to enter my input (xnew,ynew) instead of (x,y) , this function would not work. I understand the reason (because my code specifies (x,y)), but do not know how to fix it. Please help. Thank you!
function rline(x,y)
%syntax:
% rline(x,y)
line(x, y, 'Color', 'r', 'LineStyle', '--', 'LineWidth', 2)

Réponse acceptée

Ameer Hamza
Ameer Hamza le 21 Mai 2018
Modifié(e) : Ameer Hamza le 21 Mai 2018
Have you defined xnew and ynew before calling the function rline(). The name of input to the function at the definition and calling time does need to be same. Try this
xnew = 1:10;
ynew = xnew.^2;
rline(xnew, ynew);
  2 commentaires
Zoe
Zoe le 21 Mai 2018
THANK YOU!
Ameer Hamza
Ameer Hamza le 21 Mai 2018
You are welcome.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Develop Apps Using App Designer dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by