Displaying properties defined in MATLAB application
信息
此问题已关闭。 请重新打开它进行编辑或回答。
显示 更早的评论
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 个评论
Adam Danz
2020-6-25
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
2020-6-26
Adam Danz
2020-6-26
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
2020-6-26
Walter Roberson
2020-6-26
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
2020-6-29
Adam Danz
2020-6-29
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
2020-6-30
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
2020-7-4
Adam Danz
2020-7-6
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
2020-7-7
Walter Roberson
2020-7-8
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
2020-7-10
回答(1 个)
Adam Danz
2020-7-7
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 个评论
Aditya Bhatt
2020-7-10
此问题已关闭。
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


