How do I check/verify that an array is a certain dimension?

I have an array that is 1x2, but I am trying to ensure that the array MUST be 1x2 and not any smaller or larger. The array is made up of user inputs, [x,y], and I want to make sure they do not accidentally input just an X coordinate or Y coordinate. So far this is what I have. How can I ensure that they will be prompted to enter the values again until there are two values, one for x, and one for y.
What I have tried below is not working.
point = input('Please input a point [x,y]: ');
size(point);
while size(point) ~= [1:2]
point = input('Please input a point [x,y]: ');
end

 Accepted Answer

while ~isequal(size(point),[1,2])

2 Comments

This worked. Thank you so much.
You're welcome, but please Accept-click the answer to indicate that that's the case.

Sign in to comment.

More Answers (0)

Categories

Find more on Operators and Elementary Operations in Help Center and File Exchange

Products

Release

R2020a

Tags

Asked:

on 20 Apr 2021

Commented:

on 20 Apr 2021

Community Treasure Hunt

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

Start Hunting!