How do I fix the error "Function definitions are not permitted at the prompt or in scripts"?
이전 댓글 표시
I get an error when I type this:
function S = timestr(D,precision)
Here is the error:
Error: Function definitions are not permitted at the prompt or in scripts.
What does it mean?
댓글 수: 1
Jan
2011년 5월 27일
After you've edited the text, your question is clearer. And you type this in the command line? Do you want to create the function or do you have a file called "timestr.m" already?
답변 (2개)
Ben Mitch
2011년 5월 27일
Perhaps where you have
function S = timestr(D,precision)
you intended
S = timestr(D,precision)
댓글 수: 1
Fangjun Jiang
2011년 5월 27일
No. More likely is the case that Jan described.
Jan
2011년 5월 27일
2 개 추천
Is timestr a script file? Then the message is clear: A script file cannot contain function definitions.
See also:
댓글 수: 1
Fangjun Jiang
2011년 5월 27일
Aha, those posts have some use after all!
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!