functions within the script
이전 댓글 표시
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.
Rashid Hussein
2021년 6월 27일
채택된 답변
추가 답변 (1개)
Image Analyst
2021년 6월 27일
1 개 추천
Put the script first, not after the function. And make sure the function ends with an "end" statement.
카테고리
도움말 센터 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!