- Back to Home »
- MAT LAB »
- How to Create M-File In MATLAB
Posted by : Unknown
Tuesday, October 8, 2013
In this post i show you how to create M-File In MATLAB.
- Run MATLAB on your Computer. There's various method to create M-file in MATLAB.
- In old version there's option of "FILE" , Go to file and create "New M-file". But in new version there's an option of creating "New Script".
4. An editor will open like taht in figure.
5.Now write your code here.
e.g.
Implement the factorial using functions and loop
functions fact= factorial(num)
for i=num : -1 : 1
fact= fact*i
end;
end
for i=num : -1 : 1
fact= fact*i
end;
end
6. One thing is most important the function name must be the same to the M-file name.
7. Now in command window call your function like that.
"factorial(5) "
8. I hope this is helpful for you....