Passing multiple arguments, MATLAB Programming

Passing Multiple Arguments:

In many situaion it is essential to pass more than one argument to the function. For illustration, the volume of a cone is given by

120_Passing Multiple Arguments.png

here r is the radius of the circular base & h is the height of cone. Hence, a function which computes the volume of a cone requires both the radius and the height:

 

728_Passing Multiple Arguments1.png

As the function has two input arguments in function header, the two values should be passed to the function when it is called. The order makes a dissimilarity.The initial value which is passed to the function is stored in the initial input argument (in this situation, radius), and the next argument in the function call is passed to the next input argument in the function header.This is very important: The arguments in the function call should correspond one-to-one with the input arguments in the function header.

Here is an illustration of calling a function. The answer returned from the function is easily stored in the default variable ans.

>> conevol (4,6.1)

ans =

102.2065

In the next illustration, the result is printed rather with the format of two decimal places.

>> fprintf('The cone volume is %.2f\n',...

conevol(3, 5.5))

The volume of the cone is 51.84

Posted Date: 10/18/2012 7:24:11 AM | Location : United States







Related Discussions:- Passing multiple arguments, Assignment Help, Ask Question on Passing multiple arguments, Get Answer, Expert's Help, Passing multiple arguments Discussions

Write discussion on Passing multiple arguments
Your posts are moderated
Related Questions
Problem 1.  Use Matlab to solve the following system of linear equations: 2x + y + 3z = 1 2x + 6y + 8z = 3 6x + 8y + 18z = 5 Capture Matlab code and the result in a text fi

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

Matlab Scripts: Once a problem has been examined, and the algorithm for its answer has been refined and written, the algorithm then is translated into the specific programming

1;write a matlab of geuss elimination with scaling and pivoting under consideration?


An electric overhead traveling crane, consisting of a girder, trolley, and wire rope, is shown in figure. The girder has a flexural rigidity (EI) of 6x10 12 lb.in 2 and a span (L

This project carries 50% of your ?nal mark. Please hand in your work to the Mathematical and Physical Sciences School O?ce, no later than 4pm Monday 21st January 2013. Please ?l

The circuit diagram of an active filter is shown below. (a) Determine an expression for the transfer function of the filter. (b) Hence find an expression for the frequency res

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

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