Can anyone know what is the problem?
This is the the user-defined function.
This is the GUI. And when I run it, there are errors:

답변 (1개)

Mario Malic
Mario Malic 2020년 9월 6일

0 개 추천

Define your result as an empty array first. This may resolve your issues, depending on the rest of the code
result = [];

댓글 수: 4

Rik
Rik 2020년 9월 6일
This will probably solve the error, but move the problem to a later stage.
I suspect it is caused by the degree symbol. Using more complex characters like that is not the best plan, as they run the risk of being mangled.
Anyway, this function should be rewritten with switch and case. At the end an otherwise should ensure a comprehensible error is thrown.
Mario Malic
Mario Malic 2020년 9월 6일
편집: Mario Malic 2020년 9월 6일
I definately agree with the switch, case, and otherwise, as I have never used elseif statement (in my year and a half of MATLAB).
For these complex characters, it's the dropdown menu so, if done correctly, should be okay.
Actually, the issue might be that Huy had switched input arguments, therefore it fails to evaluate the result.
convert(unit, input)
convert(value, direction)
Rik
Rik 2020년 9월 6일
elseif can be easier to read. It also allows compound conditions, which can be hard or impossible to create with switch,case.
These characters need to be encoded correctly inside the mlapp file and in the m file. If you aren't using R2020a you really need to be careful about editing, as you need to make sure Matlab saves the file encoded with UTF-8, which it does by default in R2020a, but not before. Many people have lost their é characters in their comments and chars and getting them replaced with questionmarks.
Mario Malic
Mario Malic 2020년 9월 6일
Actually, I am one of those people! Thanks for the hint.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Performance and Memory에 대해 자세히 알아보기

질문:

2020년 9월 6일

댓글:

2020년 9월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by