vector match warning statement

In matlab the user to enter multiple concentrated forces [N/m] and the locations of each of the forces on the beam [m] as vectors. If the number of locations is not equal to the number of forces entered, produce a warning and prompt the user to re-enter the locations of the forces until the correct number of locations are entered.
my code
concentreated vector=[2 3 4 3[
location vector=[4 5 3 3]
Question
how do I produce a warning if the first vector does not equal the second

回答 (1 件)

Walter Roberson
Walter Roberson 2020 年 3 月 7 日

0 投票

Compare numel() the two variables to see if the same number of elements is used.
However, I recommend that you consider what should happen if the user enters two 2d arrays that have the same number of elements but a different shape, such as 2 x 6 in one case and 4 x 3 in the other. That satisfies the condition that the same number of elements are entered, but does it make sense to proceed?

カテゴリ

ヘルプ センター および File ExchangeMathematics についてさらに検索

タグ

質問済み:

2020 年 3 月 7 日

回答済み:

2020 年 3 月 7 日

Community Treasure Hunt

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

Start Hunting!

Translated by