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
Generates sin or cos wave using plot functions: The script generates an x vector; iterating through all the values from 0 to 2*π in steps of 2*π /40 gives sufficient points to

Example of Variables and assignment statements: The expression is computed and then that value is stored in the variable. For illustration, this is the way it would appear in

hey ! why the command sawtooth and square does not exist in Matlab R2012a?

how to display any words to the edittor

Random numbers: Whenever a program is being written to work with a data, and the data is not yet available, it is frequently useful to test the program first by initializing t

my project is on load frequency control using FPID tuned using GA and PSO algorithm.the system is a two area system.

For a statistically stationary environment it would be advantageous to use gear shifting, that is to reduce the adaptation gain with time. To illustrate this, try using a varying a


Code and decode a 32 bit long data for a specific user in CDMA if there is only 1 user and no noise.

design a rc phase shift oscillator for a particular frequency of oscillation and generate a sinusoidal signal