Why do my functions suddenly return values in ASCII code?
古いコメントを表示
I have made simple functions in MatLab. For example:
function add(a,b)
fprintf('%d + %d = %d\n',a,b,a+b);
end
This used to work. However, using MatLab again after a while, this same function now returns values in ASCII code. Basically, given the inputs "4" and "5",
Before:
4 + 5 = 9
Now:
52 + 53 = 105
I don't remember doing anything that would cause this change. Simply typing "4 + 5" in the command window returns 9, but the problem arises when I make functions. Advice would be appreciated. (Version: R2022a)
4 件のコメント
KSSV
2022 年 6 月 21 日
What exactly you are expecting? The code works according to the way it is written.
Stephen23
2022 年 6 月 21 日
"but the problem arises when I make functions."
The problem arises when you call functions:
Solution: use function syntax.
Winter Vee
2022 年 6 月 21 日
Stephen23
2022 年 6 月 21 日
"but I just want to fix the formatting if that makes sense."
Changing the formatting cannot "fix" the fact that you call the function with incorrect inputs.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Startup and Shutdown についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!