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

1 vue (au cours des 30 derniers jours)
Tie Dihn
Tie Dihn le 23 Jan 2022
Commenté : Tie Dihn le 23 Jan 2022
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.

Réponse acceptée

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

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Environment and Settings dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by