Unable to perform assignment because the left and right side have a different number of elements
Show older comments
I am using radio button callbacks in app designer to change variable values, and then proceed to plot with those new variables. I keep getting different errors including the one stating "the left and right side have a different number of elements" and "matrix dimensions must agree", but then sometimes it works just fine.
I think the issue might be with the callback function definition because it is intended to only take in one value but maybe its doing more than one and thats why the dimensions dont line up? Im not sure but thanks in advance for any assistance.
9 Comments
Mohsin Zubair
on 8 Jul 2021
In your callback you are using radio using values from radio buttons from another group, forexample when you change layer thickness to some other value from none to another value but the values of printing speed and soptlight Diameter are still none so basically in every case your last else never gets executed and app.valuespeed or app.valuelightd gets set and that's why you keep getting error. Basically your logic is wrong.
Luke Weger
on 8 Jul 2021
Mohsin Zubair
on 8 Jul 2021
Here try your app now, I have fixed all errors in it without changing any workflow, it should still work like you intended it to.
Mohsin Zubair
on 8 Jul 2021
Edited: Mohsin Zubair
on 8 Jul 2021
You can compare and see what I have changed as I have commented out unnecessary parts, also there's another problem that is you must select sections in last, also you must change value of intensity, cause if you don't change it, it will cause an error because you used a value change callback to set its value so if you don't change value then its value remains unset which gives an error as well, (for which I would suggest directly assigning value of intensity in RUN callback)
Luke Weger
on 8 Jul 2021
Mohsin Zubair
on 8 Jul 2021
I would suggest removing this call back
% Value changed function: IntensityWm2EditField
% function IntensityWm2EditFieldValueChanged(app, event)
% app.valueintensity = app.IntensityWm2EditField.Value;
% end
and do this instead in RUN Button callback
I_0=app.IntensityWm2EditField.Value;
Mohsin Zubair
on 8 Jul 2021
@Luke Weger if this solves your problem then accept the answer so that others may know that your question is solved.
Luke Weger
on 8 Jul 2021
Mohsin Zubair
on 8 Jul 2021
@Luke Weger it will probably be on 1st comment I made.
Answers (1)
Mohsin Zubair
on 8 Jul 2021
0 votes
You can compare and see what I have changed as I have commented out unnecessary parts, also there's another problem that is you must select sections in last, also you must change value of intensity, cause if you don't change it, it will cause an error because you used a value change callback to set its value so if you don't change value then its value remains unset which gives an error as well, (for which I would suggest directly assigning value of intensity in RUN callback)
Categories
Find more on Update figure-Based Apps in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!