Displaying properties defined in MATLAB application
Info
This question is closed. Reopen it to edit or answer.
Show older comments
How can properties defined in an application be displayed ? The properties have numerical values. I have tried using spinners and EditText Fields but there is an error in the data type.
13 Comments
Adam Danz
on 25 Jun 2020
There are lots and lots of way to display numeric and text values from an app. Your question isn't specific enought to provide a specific answer.
Could you show us the relevant lines of code that you've tried already? Also include the property values that you're trying to display and any error messages you get.
Aditya Bhatt
on 26 Jun 2020
Adam Danz
on 26 Jun 2020
Any time you reference as error in the forum, you should include the entire error message (all of it). That will tell us what's wrong.
Where is this loop? It looks like some important stuff is missing between the properties defs and the for-loop. The for-loop should be within a function, I believe, and that function should be within the methods sections.
Let's start with the error message.
Aditya Bhatt
on 26 Jun 2020
Walter Roberson
on 26 Jun 2020
I suggest putting in a couple of lines that display size() and type() of app.B before attempting the assignment to app.BSpinner.Value in order to debug the problem.
Aditya Bhatt
on 29 Jun 2020
Adam Danz
on 29 Jun 2020
According to the error, App.B is either not double, not a scalar, or it's neither. Could you add this line and show us the output?
disp(app.B) % <--- add this line
app.BSpinner.Value = app.B;
Walter Roberson
on 30 Jun 2020
I would suggest using dbstop if error
I am wondering if the error really is on that line, or if it is on the line before, the plot() call.
Aditya Bhatt
on 4 Jul 2020
Adam Danz
on 6 Jul 2020
The warning and the error are generated at different lines in the code. I'm not convinced that they are releated based on the error and warning messages.
Furthermore, the imaginary number is a double and is a scalar.
x = 1.3139 + 0.0069i;
class(x)
ans =
'double'
isscalar(x)
ans =
logical
1
Aditya Bhatt
on 7 Jul 2020
Walter Roberson
on 8 Jul 2020
Create two output fields. Set one to be the real part of B, and set the other one to be the imaginary part.
Aditya Bhatt
on 10 Jul 2020
Answers (1)
Adam Danz
on 7 Jul 2020
I just opened app designer and tried to set the value of a spinner to 1.3139 + 0.0069i. I received the same error as you.
'Value' must be a double scalar.
This is a poorly written error because 1.3139 + 0.0069i is a double and is a scalar.
class(1.3139 + 0.0069i)
ans =
'double'
isscalar(1.3139 + 0.0069i)
ans =
logical
1
But it makes sense that the spinner should be a real number.
The solution is to fix the problem with the value of app.B. My guess is that it should not be an imaginary number. Look into how app.B is being computed. If it should be an imaginary number, it's not clear to me how that would be represented in a spinner object.
1 Comment
Aditya Bhatt
on 10 Jul 2020
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

