The coins currently in Canada are nickels (worth \$0.05), dimes (worth \$0.10), quarters (worth \$0.25), loonies (worth \$1.00), and toonies (worth $2.00).

The coins I have in my pocket have a total value of \$5.75. I have twice as many dimes as nickels. I have the same number of nickels as I have toonies. The nickels and dimes together are worth \$0.50. There are a total of 10 coins in my pocket. How many coins of each type do I have?

How can I use matrices and MatLab to solve this question? Currently, what I have tried is getting 5 matrices and using those as my system of equations. [screenshot of written work]

However, when I put the matrix into RREF, I get that $a=-1.6$, $b=-3.67$, etc.

[screenshot of matlab]

I have also used logic to determine that the answer should be two nickels, four dimes, one quarter, one loonie, and two toonies.

What I want to know is the steps I would take to convert the word problem into a numerical problem, and how I would use MatLab to solve the resulting system of equations (if there even is one). This purpose of this exercise is for me to learn MatLab, and the process should only be completed using the MatLab command line.

  • $\begingroup$ It’s spelled “nickel,” just like the metal. $\endgroup$
    – amd
    Commented Sep 29, 2018 at 22:52
  • $\begingroup$ Do you have to use Matlab? Why can't you just do this by hand? It isn't hard. You definitely don't need matrices. $\endgroup$
    – John Douma
    Commented Sep 29, 2018 at 22:55
  • $\begingroup$ @JohnDouma In order to hand it in, we have to complete the problem using MatLab to demonstrate our learning. $\endgroup$
    – user594639
    Commented Sep 29, 2018 at 22:56

1 Answer 1


Let $n$, $d$, $q$, $l$ and $t$ represent the number of nickels, dimes, quarters, loonies and toonies, respectively.

From nickels and dimes being $\$0.50$ we get


Twice as many dimes as nickels gives us $$2d-n=0$$

Number of nickels equals number of toonies gives us $$n-t=0$$

Ten total coins gives us $$n+d+q+l+t=10$$

Finally, a total of $\$5.75$ gives us $$.05n+0.1d + 0.25q + l + 2t=5.75$$

These five equations and five unknowns gives you a matrix equation which you can plug into Matlab and solve.

  • $\begingroup$ Assuming the .01d is supposed to be 0.1d, this means that I was on the right track with the wrong numbers, eh? I see where I went wrong though: I made n,d,q,l, and t the values of the coins, then did a bunch of weird stuff to get essentially what you wrote. I didn't even consider n-t=0. With what you've said in mind, I'll redo the question and get back to you if the answer checks out (which it likely should, since your method is a lot more concise than my failed one). $\endgroup$
    – user594639
    Commented Sep 30, 2018 at 0:39
  • $\begingroup$ @Tropingenie I fixed the typo. Yes, $.01$ is supposed to be $.1$. $\endgroup$
    – John Douma
    Commented Sep 30, 2018 at 0:55

You must log in to answer this question.