Assignment 1

Using Matlab

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

hw1.m.

Problem 1:

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

variable r.

Problem 2:

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.

Problem 3:

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.)

Problem 4:

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

temperature.

From within your hw1.m script, test the f2c function on several inputs.

Problem 5:

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

inputs.

Problem 6:

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

inputs.

Problem 7:

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:

hw1.m

f2c.m

c2f.m

f2k.m

hw1diary.txt

Create a zip file containing a number of files.

Subject | Computer |

Due By (Pacific Time) | 11/15/2013 11:00 pm |

Tutor | Rating |
---|---|

pallavi Chat Now! |
out of 1971 reviews More.. |

amosmm Chat Now! |
out of 766 reviews More.. |

PhyzKyd Chat Now! |
out of 1164 reviews More.. |

rajdeep77 Chat Now! |
out of 721 reviews More.. |

sctys Chat Now! |
out of 1600 reviews More.. |

sharadgreen Chat Now! |
out of 770 reviews More.. |

topnotcher Chat Now! |
out of 766 reviews More.. |

XXXIAO Chat Now! |
out of 680 reviews More.. |