Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Validity = input_requirements(v)
- Validity = 1; % Assume it is valid until it isn't
- % Check the size of the input matrix
- [m, n] = size(v);
- if (m ~= 1) || (n ~= 3)
- Validity = 0; % Set it invalid
- return % Exit the function, no more checks needed
- end
- % Iterate over the matrix to check for invalid values
- for n = 1:length(v)
- % Check if it isn't a 1 or a 0
- if (v(n) ~= 0) && (v(n) ~= 1)
- Validity = 0; % Set it to invalid
- break % Exit the loop
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment