lookialoha.blogg.se

Freemat loops
Freemat loops






Use enough points for x and y (like at least 30), so that you can see the contours of the function clearly. (Note: the ellipsis, i.e., the three periods shown in the formula above, is a way in M/O/F to continue a long equation on multiple lines). Where both x and y are in the range of - 3 ≤ x, y ≤ 3. If you won the $1,000,000 State Lottery and the Lottery offered you the choice of $500,000 today or $50,000/year for 20 years, which option would maximize the amount of money you receive? You can assume an inflation (interest) rate of 5%.

FREEMAT LOOPS HOW TO

Review the lecture notes or help files to see how to structure the lines of code using the M-file (or other) text editor to make them into a function.ģ.2. Write a function in M/O/F that will compute and return the present value given the annuity, nominal yearly interest rate, and number of years as arguments (e.g., pv(A, i, n) ). P = (A/i) /(1 + i) n where A is the annuity (in $/year), i is the nominal yearly interest rate (in decimal form), n is the number of years over which the annuity is paid, and P is the present value in dollars. The present value of an annuity (a yearly sum of money) may be computed from the formula:

freemat loops

Modify the M-file code from 2.1 to annotate the plot with labels for the axes, a title for the plot, and a grid.Įxercise 3 Use one of M/O/F to solve the following problems:ģ.1. Show your lab instructor your M-file will run when you type its name to the command prompt.Ģ.3. Save it on the Desktop, and add the Desktop to the Matlab search path (File | Add path). Take the code you entered, and paste it into an M-file, named exp_plot. Include the code and the plot in your reportĢ.2. Enter and run the lines of code to the right. Use M/O/F array manipulation methods to modify the matrix from Exercise 1.4, so that the column you added in Exercise 1.4 becomes the first column instead of the third column.Ģ.1. In other words, 1 will be the top most element in the column, the next element down the column will be 2, and so forth down the column.ġ.5. Use M/O/F array manipulation methods to add a third column to the matrix from Exercise 1.3, such that its elements number off the rows. Do this using the vector v rather than having to re-type the values.ġ.4. Use M/O/F array manipulation methods to build a two-column matrix where the first column consists of the values from Exercise 1.2, and the second column consists of the values from the first column converted into degrees. If you were asked to create a vector p consisting of the last row of A, instead of simply typingġ.3. This means for you to use the abilities that M/O/F has to operate on arrays to get your required results, rather than just retyping individual elements. Note: M/O/F ‘knows’ π natively, so you can form a value like 2 π by typing: 2*pi Exercises 1.3 – 1.4 below ask you to use array manipulation methods in M/O/F to accomplish the required task. Create a vector named angles of values from 0 to 2 π radians in increments of π/10. Create a vector named v of evenly spaced values from 0 to 20 (inclusive) in increments of 1.ġ.2. For example, if displaying the contents of some array or vector will take many lines, consider showing an abbreviated set of lines that will give adequate evidence that your solution is correct.ġ.1.

freemat loops

Try to also document your output in a sensible way. One way to do this is to cutand-paste from the command window.

freemat loops

Your report must document the steps or M/O/F command used to obtain the result. Exercise 1 Use one of Matlab/Octave/FreeMat (M/O/F, for short) to do the following exercises.






Freemat loops