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

1 回表示 (過去 30 日間)
Tie Dihn
Tie Dihn 2022 年 1 月 23 日
コメント済み: Tie Dihn 2022 年 1 月 23 日
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.

採用された回答

Simon Chan
Simon Chan 2022 年 1 月 23 日
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 件のコメント
Rik
Rik 2022 年 1 月 23 日
That sounds like you could simply use a try-catch-block.
Tie Dihn
Tie Dihn 2022 年 1 月 23 日
I understood then. Thank you all!!!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeEnvironment and Settings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by