The same script works perfectly on Matlab and does not on app designer
9 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
Steven Lord
2021-2-25
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
whos A1 A2
If that's the case, convert the text data to numbers.
A3 = str2double(A1);
A2 == A3
whos A1 A2 A3
5 个评论
Steven Lord
2021-2-26
The line of code you posted uses the following variables: epsilon, m, alfa, R1, R2, Rb1, Rb2, Rc1, or Rc2. You've shown two of these variables (alfa and m) but not the other seven.
Let's check the sizes using the debugger. Set an error breakpoint and attempt to reproduce the problem. If you can, you will enter debug mode (a K>> prompt in the Command Window.) Look at the line of code where the problem occurred and look at all the variables and functions used on that line.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Develop Apps Using App Designer 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!