{"id":391,"date":"2010-08-16T15:47:11","date_gmt":"2010-08-16T15:47:11","guid":{"rendered":"https:\/\/blogs.mathworks.com\/desktop\/2010\/08\/16\/using-matlab-mobile-to-save-money\/"},"modified":"2010-08-16T16:48:04","modified_gmt":"2010-08-16T16:48:04","slug":"using-matlab-mobile-to-save-money","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/community\/2010\/08\/16\/using-matlab-mobile-to-save-money\/","title":{"rendered":"Using MATLAB Mobile to Save Money"},"content":{"rendered":"<p>This weekend my MATLAB Mobile app more than paid for itself--which is not hard, since it's free! Over the weekend I went shopping for a new car. When it was time to discuss financing, I was presented with a range of rates and promotions. In order to figure out what each combination of rates, loan amount, and length of the loan would cost me, I wrote a simple MATLAB function to do the calculations. Because I have the Financial Toolbox, I took advantage of the <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2010a\/toolbox\/finance\/payper.html\"><tt>payper<\/tt><\/a> function, which does all the exponential interest math for me. If you don't have access to that toolbox, it's some basic linear algebra to replicate that calculation. <\/p>\n<pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\"><span style=\"color: #0000FF\">function<\/span> howmuch(rate, yrs, amt)\r\nmonthly_payment = payper((rate\/100)\/12,yrs*12,amt)\r\ntotal_amount = round(monthly_payment*(yrs*12))\r\ninterest = total_amount - amt<\/pre>\n<p>With this function on my desktop MATLAB's path and the Connector running, I was able to go to the dealership confident that I could make sound financial decisions. For example, one option I had was a 2.99% APR loan, or a 3.99% loan with $1000 cash back. Using my <tt>howmuch<\/tt> function, I was able to see that while the second loan has more interest, it was overall cheaper  ($15,466 vs $16,168). An interesting thing I could have also calculated was how long the loan would have to last for the first one to be cheaper.<\/p>\n<div align=\"center\">\n<img decoding=\"async\" border=\"0\" src=\"https:\/\/blogs.mathworks.com\/images\/desktop\/michael_katz_mobile\/howmuch_mobile.png\" alt=\"Output of the howmuch function\">\n<\/div>\n<p>Because I knew that I was going to use this function from MATLAB Mobile, I coded it differently than I normally do. For example, the function does not have semicolons after each command so the values are displayed in the command window. I also used long, descriptive names for those variables since they will be printed too. Normally I would use return values, but that means extra tapping to assign outputs from the mobile command line. For the same reason, I used a function instead of a script, so I would not have to send multiple commands to change the parameter values. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>This weekend my MATLAB Mobile app more than paid for itself--which is not hard, since it's free! Over the weekend I went shopping for a new car. When it was time to discuss financing, I was presented... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/community\/2010\/08\/16\/using-matlab-mobile-to-save-money\/\">read more >><\/a><\/p>\n","protected":false},"author":38,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[54],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts\/391"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/users\/38"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/comments?post=391"}],"version-history":[{"count":0,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts\/391\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/media?parent=391"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/categories?post=391"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/tags?post=391"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}