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

Réponses (1)

Walter Roberson
Walter Roberson le 7 Mar 2020

0 votes

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?

Catégories

En savoir plus sur Mathematics dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by