cannot call m-file in another m-file

1 回表示 (過去 30 日間)
Bertiningrum Devi
Bertiningrum Devi 2019 年 6 月 20 日
コメント済み: Bertiningrum Devi 2019 年 6 月 21 日
Hi everyone!
I'm trying to call a m-file (I named it as 'trycall') in another m-file (I named it as 'callnow'),
in trycall I write:
y = 2x + 3;
in callnow I write:
clc
clear
x = 10;
trycall;
z = y;
this is what I get when I ran the code:
Error: File: trycall.m Line: 1 Column: 6
Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax error. To
construct matrices, use brackets instead of parentheses.
Error in callnow (line 5)
trycall;
I save them both in the same directory (I save them in Desktop).
I don't have any idea what I do wrong. What am I supposed to do?
Any help would be appreciated. Thank you! Have a good day.
  2 件のコメント
Stephen23
Stephen23 2019 年 6 月 20 日
"I don't have any idea what I do wrong. What am I supposed to do?"
Read the error message: "Check for missing multiplication operator..."
Bertiningrum Devi
Bertiningrum Devi 2019 年 6 月 21 日
thank you!

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

採用された回答

Walter Roberson
Walter Roberson 2019 年 6 月 20 日
y = 2x + 3;
2x is not a valid variable name in MATLAB, and it is not a valid way to write a number in MATLAB.
Like the error message said, "Check for missing multiplication operator"
  1 件のコメント
Bertiningrum Devi
Bertiningrum Devi 2019 年 6 月 20 日
my goodness... thank you!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by