How to fix this "Error using matlab.ui.control.internal.model.AbstractNumericComponent/set.Value (line 111) 'Value' must be a double scalar." ??
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I want using Appdesigner to set the simulink model parameters and change them when ever via GUI. As a simple prototype wrote 2 lines code in Appdesigner wich
through set_param() function pass the value to the simulink model. I used one numeric EditFiled and one Push Button.So when I give the value and press the button to
pass it to Simulink I face this error "Error using matlab.ui.control.internal.model.AbstractNumericComponent/set.Value (line 111) 'Value' must be a double scalar".
Here is my code:
properties(Access=private)
valueToSimulink;
end
%Callbacks that handle component events
methods (Access = private)
% Button pushed function: SaveButton
function SaveButtonPushed(app, event)
app.wEditField.Value= app.valueToSimulink;
set_param('Sinwave/Constant','w',app.valueToSimulink);
end
end
Ho can I fix this error? Is there any suggestion?
2 Commenti
Geoff Hayes
il 29 Mag 2020
Samira - where is app.value set? Given the error message, I think the error is originating from
app.wEditField.Value= app.value;
but I could be wrong. Since you mention that you are using a numeric edit field, then app.value would need to be numeric and not a string (if that is what it is). Please show the line of code where you set app.value.
Risposte (1)
Steven Lord
il 29 Mag 2020
Where do you assign a value to the private property valueToSimulink and what value do you assign to that property?
Set a breakpoint on the line of code where you try to assign app.valueToSimulink into the Value property of app.wEditField. When you reach that breakpoint, can you show the output of these commands?
size(app.valueToSimulink)
class(app.valueToSimulink)
My suspicion is that you've stored a handle to a component of your app in app.valueToSimulink, not a number. If so you probably want to store one of the properties of that component in app.valueToSimulink, not the component itself, or you want to assign app.valueToSimulink.Value to app.wEditField.Value and use app.valueToSimulink.Value in your set_param call.
0 Commenti
Vedere anche
Categorie
Scopri di più su Develop Apps Using App Designer in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!