From the course: Learning MATLAB

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Create and use a function with two inputs

Create and use a function with two inputs - MATLAB Tutorial

From the course: Learning MATLAB

Create and use a function with two inputs

- [Instructor] Let's take another example now with one output argument and two input arguments. So, we'll create a function to calculate the volume of a cone. I'm going to go again under Home tab of course. You go to New and say New Function. And we are going to repeat the same thing that we did for the first one, but now of course formula will be different and we will have two input arguments. So, where the output arguments are we are going to type V for the volume of the cone, and where the input arguments are we are going to write r for radius comma h for the height. So, the volume of the cone formula is equal to pi times r squared times height divided by three. So, you'll see the formula here. And then we are going to type here. This function is used to calculate the volume of a cone, and we can make a space here and delete the detailed explanation. But also we need a name for the file or for the function. And the…

Contents