Self-written function does not work when changing input names

1 回表示 (過去 30 日間)
Zoe
Zoe 2018 年 5 月 21 日
コメント済み: Ameer Hamza 2018 年 5 月 21 日
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)

採用された回答

Ameer Hamza
Ameer Hamza 2018 年 5 月 21 日
編集済み: Ameer Hamza 2018 年 5 月 21 日
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 件のコメント
Zoe
Zoe 2018 年 5 月 21 日
THANK YOU!
Ameer Hamza
Ameer Hamza 2018 年 5 月 21 日
You are welcome.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by