Variable number of output arguments - function, MATLAB Programming

Variable number of output arguments:

The variable number of output arguments can also be identified. For illustration, the one input argument is passed to the below function typesize. The function always return a character identifying whether the input argument was a vector ('v'), scalar ('s'), or matrix ('m'). This is returned through the output argument arrtype. In addition, when the input argument was a vector the function returns the length of the vector, and when the input argument was a matrix the function returns the number of rows & columns of the matrix. The output argument varargout is used; and it is a cell array. Therefore, for a vector of length is returned through the varargout and for a matrix both the number of rows & columns are returned through the varargout.

677_Variable number of output arguments.png

>> typesize(5)

ans =

s

>> [arrtype, len] = typesize(4:6)

arrtype =

v

len =

  3

>> [arrtype, r, c] = typesize([4:6;3:5])

arrtype =

m

r =

2

c =

3

Posted Date: 10/22/2012 1:19:50 AM | Location : United States







Related Discussions:- Variable number of output arguments - function, Assignment Help, Ask Question on Variable number of output arguments - function, Get Answer, Expert's Help, Variable number of output arguments - function Discussions

Write discussion on Variable number of output arguments - function
Your posts are moderated
Related Questions
A 12-point sequence is x (n) defined as x(n) = { 1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 1}. Write MATLAB programs to (a) Determine the DFT X (k) of x(n) and plot (using stem function)

how to find matrix inverse using matlab command

what are the steps we need to write in the script to get themedian for X values

Creating Matrix Variables: Creating a matrix variable is actually just a generalization of creating a row and column vector variables. That is, the values within the row are s

Consider the 3rd order Bessel function J3(x). Write a script findBessRoots.m that computes all the roots of J3(x) in the interval [0; 40]. Your script must store the roots of the f

Read in any non jpeg image (any image will do) . Save it as a jpeg at quality levels (70, 60,50,40, 30) Get the MSE for each quality level as compared to the orignal file Get the

conversion of decimal to binary

i made graph using adjacent matrix i have to find the critical path on that graph in matlab work can you please give me that code.

Creating Column Vectors: One way to generate a column vector is by explicitly putting the values in square brackets, separated by the semicolons: >> c = [1; 2; 3; 4] c =

how to write a program to determine the day of the week. using GUI.