MATLAB: What is the error “Value must be a double scalar” in Matlab appdesigner? Error using matlab.ui.​control.in​ternal.mod​el.Abstrac​tNumericCo​mponent/se​t.Value (line 111) ‘Value’ must be a double scalar.

app designerdouble scalarerror

While using app designer I wanted to save the data which the user inputs to an array. I do some calculations from them and when showing the result in the output feilds of the app, it gives me an error like this.
Error using matlab.ui.control.internal.model.AbstractNumericComponent/set.Value (line 111)
'Value' must be a double scalar.
I have attached the screen shots and below is the code. I created a function called `check`. It´s purpose is to tell the user to enter values in the blank feilds if they are empty.
I call the above function when the "result" button of the GUI is pressed. So I call ´check´ function inside the `buttonPush` function.
I use `twodecision1` and ´twodecison2´ variables as outputs. Values this two variables are assigned later written back to the GUI feilds as a display to user. Here´s the part I get error. It seems I try to assign wrong data type. Thank you in advance.
properties (Access = private)
two = [1 2; 3 4; 5 6; 7 8] ; %to store input data from GUI
twodecison1 ; %output variable

twodecision2; %output variable
end
methods (Access = private)
function results = check(app)
results = app.twodecison1;
results = app.twodecison2;
if(app.two(1,1)==0 && app.two(1,2)==0 && app.two(2,1)==0 && app.two(2,2)==0 && app.two(3,1)==0 && app.two(3,2)==0 && app.two(4,1)==0 && app.two(4,2)==0 )
app.twodecison1 =0;
app.twodecison2=0;
app.outputmessageEditField="Fill the requires feilds";
end
end
end
methods (Access = private)
% Code that executes after component creation
function startupFcn(app)
end
% Button pushed function: resultsButton
function buttonPush(app, event)
app.two(1,1) = app.StrokelengthEditField.Value;
app.two(1,2)= app.strokelengthEditField.Value;
app.two(2,1)=app.pitchEditField.Value;
app.two(2,2)=app.pitchEditField_2.Value;
app.two(3,1)=app.buildingdimensionEditField.Value;
app.two(3,2)=app.buildingdimensionEditField_2.Value;
app.two(4,1)=app.preconfignumEditField.Value;
app.two(4,2)=app.preconfignumEditField_2.Value;
app.actuator1refnoEditField.Value= app.twodecison1 ;
app.actuator2refnoEditField.Value= app.twodecison2 ;
app.check();
end
end
1.PNG

Best Answer

I solved this. I saved the output into another array instead of single variables as decision1 and decision2.