The program doesn't re-read variables's values in Matlab app.designer
8 views (last 30 days)
I made the following program in matlab app.designer.
The point here is that you introduce the variables "m" and "a" in whatever editfields on the left and their numeric values in whatever fields on the right.
Then, by clicking on CALCULATE button it appears the value of the Force (F=m*a) in the centre as you can see in the image
Then, you click on REFRESH button and the numeric values return to 0 and the text values return to empty.
Everything goes fine right to that point.
The issue here is that after clicking on REFRESH, and I want to introduce again variables and values...the program no longer reads the variables and their values, so the program doesn't calculate the value of the force of course. Just it doesn't do anything and appears that error on the command window. (By the way, app's code goes just until line 155, I don't know what that line 335 means.)
The code I have used for CALCULATE button and REFRESH button are those:
Thank you very much.
Rik on 13 Jan 2021
You should probably consider stripping all whitespace from the user input.
This looks to me like the value in the text field is not equal to either of your branches, meaning m is not defined. You are also using == to compare char arrays, instead of strcmp (which would also handle strings and will handle arrays of dissimilar size).
%make sure your user gets an error here, or set default values
Another possibility is to use a dropdown menu or radio buttons to allow the user to select variables.