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
Various commands for get the help: There are various commands which can serve as an introduction to MATLAB and allow you to get the help: info will show contact informatio

This assignment is motivated by the use of flybys of planets / moons in spacecraft missions to alter a spacecraft's trajectory (flight path). Planetary flybys can be used to not on

i need help with a monte carlo simulation. I have most of the code, but I can''t get it to plot correctly

Produce a random real number: To produce a random real number in the range from low to high, at first create the variables low and high. And then, use the expression rand*(hig

Function char: The function char does the opposite; it converts from any number type to the type char: >> char(numequiv) ans = a As the letters of the alphabet are

1. Enter the 3×4 matrix Let a ij denote the entry of A in the ith row and jth column. Use Matlab to compute the following : (a) a 13 + a 32 (b) Three times the

MATLAB is a high-performance language for technical computing. It integrates computation, visualization, and programming in an easy-to-use environment where problems and solutions


Why Function stubs are used?

This problem description is taken from Illingworth and Golosnoy [1]: For physical systems of inhomogeneous composition, di usion is often observed to cause a change of phase, even