For this assignment, you will write a script m-file called
hw1.m. There are multiple exercises in this assignment, be sure to
label your solution to each exercise with a comment. Some of the
exercises ask for additional m-files that will be called from within
In hw1.m, create a variable called r with the value 25. Write
expressions in matlab to calculate and display the diameter, the
circumference, and the area of a circle with the radius stored in the
Run help on the "rand" function. Read about how it works. Create
three variables, rand1, rand2, and rand3. Each should contain a
random number between 0 and 1. Make sure to both run the help command
and assign the variables from the script hw1.m.
Recall the quadratic equation (a*x^2 + b*x + c = 0). In your hw1.m
script set a equal to 1, b equal 0, and c equal -9 then write two
expressions to calculate the roots of this equation. (Hint: if you
don't remember it, look up the quadratic formula and use that as a
template for your two expressions.)
Write a function called f2c (in the file f2c.m). The purpose of this
function is to convert degrees Fahrenheit to Celsius. The function
takes as an input argument the temperature in Fahrenheit. It should
return a single output argument with the corresponding Celsius
From within your hw1.m script, test the f2c function on several inputs.
Write a function called c2f (in a the file c2f.m). This function
takes as input a temperature in Celsius and returns as output the
corresponding temperature in Fahrenheit.
From within your hw1.m script, test the c2f function on several
Write a function called f2k (in the file f2k). This function will
take a value in Fahrenheit and return the corresponding temperature in
Kelvin. Within the f2k function, you should call the f2c function first and
then calculate the Kelvin value in terms of its result.
From within your hw1.m script, test the k2f function on several
Create a diary file called hw1diary.txt that contains the output of
running the hw1.m script.
What you need to submit:
After you have successfully completed this assignment you will have a
number of files:
Create a zip file containing a number of files.
|Due By (Pacific Time)||11/15/2013 11:00 pm|
out of 1971 reviews
out of 766 reviews
out of 1164 reviews
out of 721 reviews
out of 1600 reviews
out of 770 reviews
out of 766 reviews
out of 680 reviews