MATLAB Function Tutorial

00:00 – Introduction
00:33 – General form
01:26 – Example function declaration
02:08 – Calling a function
03:05 – Function workspace isolation
04:30 – Example function code
05:49 – Explanation of function code
06:31 – Calling a function with fewer output arguments
07:08 – Conclusion

• Views:115,466 views
• Rating:
• Categories:
• Tags:

Joe L. says:

Thanks a lot, it was really useful.

Greetings from Spain!

Rishabh Vyas says:

Hey, if I have to create a function with 2 input arguments (vectors) and the output should be the value of the derivative, how is it written?

HollywoodVEVO says:

SALAM! My matlab says “The selected cannot be evaluated because it contain invalid statement” WHILE i have tried different techniques… even wrote as same as yours…

Diamond Blooded says:

Hi I was wondering if you have any expertise with the “comet” function and would be able to help me sort out some code?
I have this code here:

a=(1:0.5:1000);
angle=a.*75;
x=cos(angle);
y=sin(angle);
t=0.5;
Ex=x.*Er;
Ey=y.*Er;
DELAY = 1;
%edit comet
%axis=5*10^12;
comet(Ex,Ey,0)
%axis([-axis axis -axis axis]);

And it works except for the fact that it’s too fast! I can’t get it to slow down with any pause or delay functions, any ideas?

yamen kezel says:

how can i input any function i want in matlab. i mean something like (input(‘enter yout function’))
ty

djokatore45 says:

thank you for this example, very helpful 🙂

ابو حضرم says:

than u very much

Michael Ellison says:

well said!

Mohamed AbdelFattah Ali says:

Thanks a lot.

w George says:

very good!!!

Ahmed Albidhany says:

Hey, How to write a function that its number of outputs depends on the value of its input…for example:
[n1,n2,………nr]=myfunction(r)

is this possible in Matlab?

Eric Arnaud says:

Thank you so much, that was awesome explained

Nev Pires says:

Great Video!

John T. Deck says:

Thank you SO much! It’s 3 am and I’ve been struggling so much! You are amazing.

vALIents InfoTech says:

For more understanding watch this video:
https://youtu.be/t6062Nwt0JE

anzar zahid says:

Thanks a lot, it was really useful.

nacht98 says:

very very good!

Andy Westwood says:

An outstanding tutorial, clear and with valuable common/standard practice issues. Same for the other tutorials on your channel. A very good balance between capability and options.
Thanks so much ….

Tim Buck says:

function function function function function function function function function function function function function function function function function function function function function function function function function function function function function function

MyThoughtsAreBelow says:

Excellent tutorial sir

moses mccabe says:

wow just awesome. thanks for this very detail and well explain video

Giuseppe Scarlatino says: