function error (GUIDE)

2 ビュー (過去 30 日間)
Kristin Habersang
Kristin Habersang 2021 年 6 月 25 日
コメント済み: Walter Roberson 2021 年 6 月 25 日
Hello, I'm getting error messagges at the end of my GUIDE script and i don't know what i should do.
I didn't change anything, that's just what the program did.
Can someone help me?
Thank you!
  1 件のコメント
Walter Roberson
Walter Roberson 2021 年 6 月 25 日
There is a red mark near the top. You need to look at that error: it is probably causing the other errors.
I suspect that there is an if without end or [ without ] or something like that.

サインインしてコメントする。

採用された回答

Nikhil Sapre
Nikhil Sapre 2021 年 6 月 25 日
編集済み: Nikhil Sapre 2021 年 6 月 25 日
Hi Kristin,
Based on the snippet of code you posted, I see that the function blocks don't have an end. Hence the errors.
Here's an example of how a fucntion declaration should look like
function ave = average(x)
ave = sum(x(:))/numel(x);
end
Please refer to the the documentation on how to declare function in MATLAB for more details
Thanks,
Nikhil
  1 件のコメント
Walter Roberson
Walter Roberson 2021 年 6 月 25 日
GUIDE has gone through several generations. In most of the generations, it uses functions that do not end with end . That is perfectly acceptable. As the link you posted indicates,
The end keyword is required when:
  • Any function in the file contains a nested function.
  • The function is a local function within a function file, and any local function in the file uses the end keyword.
  • The function is a local function within a script file.
and GUIDE never uses nested functions and does not generate a script, so end would only be needed if some local function used end .
Does GUIDE generate local functions with end ? Traditionally it did not. I have seen some hints that it might have done so in the very last couple of releases before it was retired... but it is also possible that people had hand-editted the code I was looking at.
Does the user have the situation where an end was used for a local function at some point? I cannot rule that out. However, when that happens, there is a specific error generated about how at least one local function had an end but other ones did not.
Unfortunately my system is quite busy at the moment so I cannot test to be sure exactly what is going on.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by