MATLAB: How to generate a function that takes a 3-element column vector as an input and returns three output arguments

matrixmatrix array

Hi every body of my Matlab friends..i have question about my beginner study assignment…The question begins like this.. SO i need your help if any body could help me,i would appreciate it ..
Write a function called chop that takes a 3-element column vector as an input and returns three output arguments. The function must check the format of its input. Namely, it must determine whether the input satisfies the following two restrictions: (1) it is a column vector and (2) it contains exactly three elements. If either or both of these restrictions are violated, then the function prints “Invalid input!” and returns three zeros. Otherwise, it sets each of the output arguments equal to the value of one of the 3-elements of the input vector in the order that they occur in the vector and prints nothing.

Best Answer

Obviously, a function that's supposed to take one vector as input will have exactly one input argument. So the signature of your function should be:
function [A, B, C ] = chop(v)
You can then test within the function the shape and number of elements of that vector.