Error: Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters
7 ビュー (過去 30 日間)
古いコメントを表示
My function is below.
function original_rest_analysis_conn(subjname{s},'csd',{'F1','F3','F5','FC1','FC3','FC5'},{'F2','F4','F6','FC2','FC4','FC6'},{'CP1','CP3','CP5','P1','P3','P5'},{'CP2','CP4','CP6','P2','P4','P6'},1,1,4,7)
Matlab keeps on telling me:
Error: File: original_rest_analysis_conn.m Line: 1 Column: 46
Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched
delimiters.
The same parentheses are used in the code as it is used in the above function. There is more code after this function (cannot share as it is not mine) and there seems to be no other issue with the rest of the code. Any help would be appreciated.
0 件のコメント
回答 (1 件)
Steven Lord
2021 年 1 月 12 日
編集済み: Steven Lord
2021 年 1 月 12 日
When you define a function the inputs must be specified as variable names in the definition. [Slight oversimplification, but good enough for right now.]
When you call a function the inputs must be specified as the values you want those variables to contain.
This is a valid function definition.
function y = addme(a, b)
y = a+b;
end
This is a valid way to call the function addme.
output = addme(4, 5) % output will be 9
This is not a valid function definition.
function y = addme(4, 5)
y = a+b;
end
This is not a valid function call unless the variables a and b have already been defined.
output2 = addme(a, b);
As written you're trying to do something like the "This is not a valid function definition." section of the example above.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Entering Commands についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!