The same script works perfectly on Matlab and does not on app designer

17 views (last 30 days)
I have made a code which the user enters as inputs several variables and when running the code, it (the code) calls several scripts to calculate the oututs. If I execute it on command window or even in the script itself, it works perfectly.
The point is that I am implementing it on matlab app designer. In an app that when you click the button, the code calls the scripts and the program gives the outputs to the user. So, here, when the code calls one of the scripts called "jENG000_ca1", matlab gives me the following error on the jENG000_ca1 script's line 53.
Here is exactly the code in that line:
if (epsilon==6969)&&(m~=6969)&&(alfa~=6969)&&(R1~=6969)&&(R2~=6969)&&(Rb1~=6969)&&(Rb2~=6969)&&(Rc1~=6969)&&(Rc2~=6969) %line 53
[epsilon,R1,R2,Rc1,Rc2,ro1,ro2,alfa,m]=epsilon00(epsilon,R1,R2,Rc1,Rc2,ro1,ro2,alfa,m) %line 54
end %line 55
I have tried also with the parenthesis (as you can see in the image) and without them and it works perfectly on matlab and on the script, but as you can see, does not work in matlab app designer.
How can I solve this? As long as I know, I am not doing anything wrong.
Thanks a lot

Accepted Answer

Steven Lord
Steven Lord on 25 Feb 2021
My guess is that when you call the function in the Command Window or script you're calling it on scalar data but when you call it in App Designer you're calling it with non-scalar data.
This could happen if one or more of the variables epsilon, m, alfa, R1, R2, Rb1, Rb2, Rc1, or Rc2 are being read from an edit box in the app and are being read not as numeric data but as text.
A1 = '12345';
A2 = 12345;
A1 == A2 % None of the characters '1', '2', '3', '4', or '5' are equal to 12345
ans = 1x5 logical array
0 0 0 0 0
whos A1 A2
Name Size Bytes Class Attributes A1 1x5 10 char A2 1x1 8 double
If that's the case, convert the text data to numbers.
A3 = str2double(A1);
A2 == A3
ans = logical
1
whos A1 A2 A3
Name Size Bytes Class Attributes A1 1x5 10 char A2 1x1 8 double A3 1x1 8 double
  5 Comments
ErikJon Pérez Mardaras
ErikJon Pérez Mardaras on 26 Feb 2021
I have found the issue.
The point is that epsilon wasn't defined, so it had no value, thus, it was a 0x0 size variable. Once I define the value of epsilon (as it was supposed to work like), the problem is resolved
Thanks for the help!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by