Self-written function does not work when changing input names

1 Ansicht (letzte 30 Tage)
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)

Akzeptierte Antwort

Ameer Hamza
Ameer Hamza am 21 Mai 2018
Bearbeitet: Ameer Hamza am 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);

Weitere Antworten (0)

Kategorien

Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by