# Writing a function m-file in MATLAB - Stack Overflow.

Given a uniform distribution of a variable, use a function of random variables to plot the probability density function MATLAB 1 Plotting a function of Theta and Phi as a color plot on a sphere. Step 1: How to Open a Function File. Open the MATLAB software on your computer. Once you open MATLAB, open a new script file by double clicking the “new script” icon on the top left of the MATLAB file, as in the picture above. M-File Functions. Functions are program routines, usually implemented in M-files, that accept input arguments and return output arguments. They operate on variables within their own workspace. This workspace is separate from the workspace you access at the MATLAB command prompt. After the m-file is saved with the name filename.m in the current MATLAB folder or directory, you can execute the commands in the m-file by simply typing filename at the MATLAB command window prompt. If you don't want to run the whole m-file, you can just copy the part of the m-file that you want to run and paste it at the MATLAB prompt. The definition is inside the first .m file you described. It is important that there is only one function per file (excluding things like local, anonymous and nested functions) and that the file has the same name as the function. In your case, the file containing the function hog has to be called hog.m. Inside the script, you run or call functions. Question: Write A MATLAB Function M-file, MyFact, To Input A Number, X, Between 1 And 10 Compute And Return As Output The Factorial, X!. Use A For-loop. Do Not Use Built-in Functions Factorial Or Prod. No Credit Will Be Given For Using These Functions If X Is An Array, The Program Should Display A Message, And Halt If X Is Not A Number Between 1 And 10, The.  Write (and demonstrate) a MATLAB function m-file that meets the following requirements: a. Has three input arguments (in order): an initial x value, a final x value, and a function handle (e.g. to an anonymous function). b. Has two output arguments (in order): an x vector, and a y vector. c. I am writing a GUI for an existing program. This program runs an M file (currently users specify which to run manually editing the code) which contains data and some calculations - there are hundreds of these M files for different users, that contain data about them. Write a MATLAB function M-file, DetermineState, that receives a temperature in Fahrenheit as input, and returns a number as output that corresponds to its state return 0 if solid return 0.5 if in solid-liquid transition return 1 if liquid.  You wrote the function incorrectly. You don't want this to be a recursive function so don't call array() inside of array(). You should have used a() instead of array() because a is the matrix while array is your function's name. Also note that MATLAB is case sensitive so Array and array are different.