Release a Message in GUI to user when calculation can't be performed

1 view (last 30 days)
Hello everyone,
I am writing an app in GUI to make calculation on Matrices such as: addition, Substraction,...,
But how could I release a message when two entered matrices (say A, B) have their dimensions to be not matched to perform the operation like: A+B (e.g size(A)=[2,3],size(B)=[2,2],..).
Thank you.

Accepted Answer

Simon Chan
Simon Chan on 23 Jan 2022
A sample example as follows, you may modify it to suit your purpose:
A = [1 2 3 4; 2 3 4 5];
B = [3 4 5; 4 5 7];
fig = uifigure;
if any(size(A)~=size(B))
uialert(fig,'Dimensions of matrix A & B are not matched','Warning','Icon','warning');
else
C = A+B;
uialert(fig,'Calculation finished','Message','Icon','success');
end
  3 Comments

Sign in to comment.

More Answers (0)

Categories

Find more on Environment and Settings 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!