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

1 Ansicht (letzte 30 Tage)
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.

Akzeptierte Antwort

Simon Chan
Simon Chan am 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 Kommentare
Rik
Rik am 23 Jan. 2022
That sounds like you could simply use a try-catch-block.
Tie Dihn
Tie Dihn am 23 Jan. 2022
I understood then. Thank you all!!!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Environment and Settings finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by