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

1 visualizzazione (ultimi 30 giorni)
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.

Risposta accettata

Simon Chan
Simon Chan il 23 Gen 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 Commenti
Rik
Rik il 23 Gen 2022
That sounds like you could simply use a try-catch-block.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Environment and Settings in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by