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
You will write functions • B=null basis(A,tol); • B=range basis(A,tol); The function null basis takes a matrix A as input, and outputs a basis for the null space of A, obtained via

Write a MATLAB program that calculates the arithmetic mean, the geometric mean, and the root-mean-square average for a given set of values. Your program must use 3 functions t

#create a matlab GUI for designing common emitter amplifier which produces AC load lines based on the component values

Find the boundary between each two of the equations P1, P2, P3 by solving: P1 = P2  ,  P1 = P3  ,  P2 = P3 Plot the boundary lines on a single figure that also includes the

illustration of for loop: illustration, to print a column of numbers from 1 to 5: for i = 1:5 fprintf('%d\n',i) end   This loop can be entered in the Command Wi

The MATLAB system having of five main parts: * Handle Graphics. * The MATLAB working environment. * The MATLAB language. * The MATLAB mathematical function library.

Answers should be submitted in an MS Word document. Simulations should accompany answers in a separate MATLAB file. 1)  Queuing Simulator: Consider a communications router that

#defining matrix using only special commands

The characteristic properties of an aquifer can be used to calculate groundwater velocities, v groundwater (L/T), according to: where KH (L/T) is the hydraulic conductivit

Problem 1:   What are the different methods that can be used to solve a differential equation? Please provide a numbered list. Problem 2:   For a first order linear d