Mathlab Exercise

All problems must be formatted correctly in the report to obtain full points. Code must be well
commented and sectioned. Any information missing from the report or the simple act of typing
out results in MATLAB and calling those results will result in a zero for the grade. If you have
any questions or comments feel free to join office hours or to email me.
Problem 1
We will be writing code and comparing them to built-in functions in MATLAB so we can
understand how to write code and how to call built-in functions. Use fprintf to output all your
a) Write a piece of code that solves the quadratic equation from the user’s input, compare it
with the roots function.
a. Use a =5; b= 4, c =7 as your test variables
b) As the user to input a minimum of 5 number inputs. Write a piece of code that solves for
the mean and standard deviation of user input values. Compare those with the built-in
functions in matlab that solve for the mean and the standard deviation.
a. Use values 2,4,7,9, 2 as your test variables.
Problem 2
You are given this data set that is a set of measured height, slant length, and perimeters for a
Right Rectangle Pyramid :
H = Height = [] L = Length = [] W = Width = []
You need to
1) Import data correctly and set them equal to any variables name of your choosing.
2) Find the max, min, and average value for vectors height, length, and width.
3) Use the max, min, and average values to determine the surface area of a pyramid by using
this equation :
Use fprintf to output all your results and suppress all other outputs. If you do not import the data
correctly you will only receive ½ the credit for this problem.

Problem 3:
Some how we have gotten in contact with Einseins long lost third cousin, twice removed. Well
they have been working on a chemical treatment that “SUPPOSIBILY” reduce tenage ache…
They ended up with a model that represents their formula for the secret treatment that they have
developed. So this cousin can do everything except learn how to code, they were wondering if
you could help reduce the model into a simple equation.
Since we are proud Sun Devels and have already taken algebra and know how to code we decide
to help them out. The formula/model for the secret ingredients is:
𝐴 – 2𝐵 + 2𝐵𝑌 +
𝐵2 − 𝐴 +𝐵2(3 − 4𝑌) − 3𝑌𝐵 + 3𝐵𝐴𝐶 +𝐶𝐵 𝐵2 1𝐶(𝐶 + 𝐴 + 7𝐶𝐵 − 𝐴)

Don't use plagiarized sources. Get Your Custom Essay on
Mathlab Exercise
Just from $13/Page
Order Essay

Where the variables are defined as :
A =Secret Ingredient 1 B= Secret Ingredient 2 C= Water Y= Secret Ingredient 3
To explain the formula a bit more, if we have 3*C that means we added 3 (unit) of water, if it says -½ * B
it means that we need to reduce the concentration of 1 (unit) of secret ingredient 2 by half. The logic
behind the model and the practice are very iffy they say its a work in progress.
a) Simplify the combination formula for “treatment” by hand and compare it to that which
MATLAB produces with 50 steps to solve. Are they the same? What are some benefits of using
the MATLAB simplify function?
b) What if the inputs for this specific combination were given in grams, using an anonymous
function what would be total weight of the combination in grams, if you need 5% of a 200 gram
of Secret Ingredient 1, 26% of a 100 gram of Secret Ingredient 2, 70% of a .07 liter is Water,
10% of 10 grams of Secret Ingredient 3.
(None of these measurements are not true, but will be considered for this assignment)
Two extra credit Problems ( Do as many as you can):
– Let’s say that the weights were given in different units, use the simplify function to
reduce the units and equation correctly if Secret Ingrerdient 1 is in kg , Secret Ingredient
2 is in g, Water is in kg and Secret Ingredient 3 is in mg.
– How much time does MATLAB say it takes to solve for the weight with the simplified
equation vs the simplified equation?


and taste our undisputed quality.