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
Use Taylor series to derive the form of the truncation error of the approximation Suppose f € C3. Given that the roundo error has the similar form as in the Forward D

please tell me the procedure of Anova two Way analysis in matlab?

We wish to numerically perform the following integration: (a) Use Matlab's quad function to perform the above integral. (b) Analytically evaluate the integral (e.g. do t

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

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

A filter described by the equation:    y(n) = x(n) + x(n-1) + 0.9 y(n-1) - 0.81 y(n-2) (a) Find the transfer function H(z) for the filter and find the poles and zeros of the fil

You are given data similar to the examples and sample problems in the statistics topic. Write MATLAB program to do the following: 1. Plot histogram, relative frequency histogram


Common form of a function definition: The common form of a function definition for a function which computes and returns one value looks like this: For illustration, t

Consider the function: f(x) = 7 - 28x + 42x 2 - 28x 3 + 7x 4 : Write a script findPolyRoot.m to nd, as accurately as you can, the root of f(x) near x = 2. Your script mu