Basic calculator not working in app designer.
2 views (last 30 days)
Show older comments
Karel Starý
on 21 Apr 2021
Commented: Karel Starý
on 21 Apr 2021
Hello guys!
I have to create an app for my work, so I have started with MatLab recently. I really like the App Designer tool, so I have given it a try. I do not have anyone to ask this (I believe an easy question) so would appreciate any reply.
I have basic app that should take two variables form a user, multiply it and give a result back.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/591875/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/591880/image.png)
First four fields are numbers field and the last one is text filed. I have tried to switch them but this seems to be not causing the issue I have.
I declare the fields from when we should get the variables h and m from. Then I created two fields to be able to confirm that variables are defined as expected.
When I try to run the code it give me this message: Error using matlab.ui.control.EditField/set.Value (line 99)
'Value' must be a character vector or a string scalar.
From the app window it's clear that m and h have values I want. But there is some problem with last variable I am not really able to grasp. .
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/591885/image.png)
I havetried to read the documentation on how to declare variable in classic MatLab and in App developer but no luck for me there.
Can someone please explain this to me in easy way because I might be dumb.
0 Comments
Accepted Answer
Johannes Hougaard
on 21 Apr 2021
I think that as the error message states the .Value field of the EditField must be a string rather than a number.
This could probably be fixed by
app.resultEditField.Value = string(result);
More Answers (0)
See Also
Categories
Find more on Develop Apps Using App Designer in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!