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

Risposte (1)

Walter Roberson
Walter Roberson il 7 Mar 2020

0 voti

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?

Categorie

Scopri di più su Mathematics in Centro assistenza e File Exchange

Tag

Richiesto:

il 7 Mar 2020

Risposto:

il 7 Mar 2020

Community Treasure Hunt

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

Start Hunting!

Translated by