functions within the script
2 ビュー (過去 30 日間)
古いコメントを表示
i wanted to call the same function several times but with different variables eachtime in the same script
for example
function [a]=myfunction(r)
a=10*r
end
a=myfunction(5)
a=myfunction(7)
i want when run the script to have all results at once but it shows this error message
Error: File: myhot.m Line: 5 Column: 2
This statement is not inside any function.
(It follows the END that terminates the
definition of the function "myfunction".)
thankyou
2 件のコメント
Akshit Bagde
2021 年 6 月 27 日
If you are writing a script file which contains both commands and function definitions, the functions must be placed at the end of the file. Read about it here - Declare Functions in MATLAB.
採用された回答
その他の回答 (1 件)
Image Analyst
2021 年 6 月 27 日
Put the script first, not after the function. And make sure the function ends with an "end" statement.
参考
カテゴリ
Help Center および File Exchange で Time Series Collections についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!