Matlab help can't write script

• January 27th 2010, 07:23 PM
Mathhelpz
Matlab help can't write script
Q-2e One type of candy costs 60 cents a pound while a second type costs 80 cents a pound. How many pounds of each type must be combined in order to produce 20 pounds of a mixture worth 75 cents a pound?

type 1 =x
type 2 =y
x+y=20
y=20-x

60x+80y=75(x+y)
60x+80y=75x+75y
simplify
5y=15x
sub in y=20-x
5(20-y)=15x
100-5x=15x
100=20x
x=5
plug 5 into y=20-x
y=15

Could someone help me form a matlab script?
• January 27th 2010, 11:07 PM
CaptainBlack
Quote:

Originally Posted by Mathhelpz
Q-2e One type of candy costs 60 cents a pound while a second type costs 80 cents a pound. How many pounds of each type must be combined in order to produce 20 pounds of a mixture worth 75 cents a pound?

type 1 =x
type 2 =y
x+y=20
y=20-x

60x+80y=75(x+y)
60x+80y=75x+75y
simplify
5y=15x
sub in y=20-x
5(20-y)=15x
100-5x=15x
100=20x
x=5
plug 5 into y=20-x
y=15

Could someone help me form a matlab script?

You have the pair of equations:

$x+y=20$

$60x+80y=75\times 20$

or in matrix form:

$\left[ \begin{array}{cc}1&1\\60&80\end{array}\right] \left[ \begin{array}{c}x\\y \end{array} \right] =$ $\left[ \begin{array}{c}20\\1500 \end{array} \right]$

So is we set:

$
\bold{x}= \left[ \begin{array}{c}x\\y \end{array} \right]
$

We can write:

Code:

A=[1,1;60,80]; Z=[20;1500]   X=A\Z
or of you prefer:

Code:

A=[1,1;60,80]; Z=[20;1500]   X=inv(A)*Z
CB
• January 28th 2010, 05:00 AM
Mathhelpz
thank you very much@!