Passing multiple arguments, MATLAB Programming

Assignment Help:

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


Related Discussions:- Passing multiple arguments

Operators, Operators: There are in general two types of operators: una...

Operators: There are in general two types of operators: unary operators that operate on a single value or operand; and binary operators, that operate on two values or operands

Image and video compression, Read in any non jpeg image (any image will do)...

Read in any non jpeg image (any image will do) . Save it as a jpeg at quality levels (70, 60,50,40, 30) Get the MSE for each quality level as compared to the orignal file Get the

Calculate the mean-mode and median, You are given data similar to the examp...

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

DC Motor, I need assignment to finish.

I need assignment to finish.

Size function - dimensions of matrix, Size function - Dimensions of matrix:...

Size function - Dimensions of matrix: For the matrix mat shown next, it has three rows and two columns, therefore the size is 3 × 2. The length is the larger dimension that is

Calculate power system blockset model, For the 66kV subtransmission network...

For the 66kV subtransmission network shown below, calculate the following, using a MATLAB Simulink Power System Blockset model: 1. Three phase, phase-to-phase and phase-to-earth

Matlab function to find and plot the dft, It is desired to determine the DF...

It is desired to determine the DFT of the analogue signal x (t) = 25 cos(10 Πt)cos(400Πt). (a) Find the Nyquist rate of the signal.   (b) What is the record (signal) length i

Missing commands, hey ! why the command sawtooth and square does not exist ...

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

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd