How do I fix the error "Function definitions are not permitted at the prompt or in scripts"?

5 ビュー (過去 30 日間)
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
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
Ben Mitch 2011 年 5 月 27 日
Perhaps where you have
function S = timestr(D,precision)
you intended
S = timestr(D,precision)

Jan
Jan 2011 年 5 月 27 日
Is timestr a script file? Then the message is clear: A script file cannot contain function definitions.
See also:

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by