![]() |
Mathematical Word Problems – Construction Tool
[B] [URL="https://blogs.mathworks.com/loren/2019/07/30/mathematical-word-problems-construction-tool/"]Mathematical Word Problems – Construction Tool[/URL] [URL="https://blogs.mathworks.com/loren/2019/07/30/mathematical-word-problems-construction-tool/#view_comments"]5[/URL][/B]
Posted by [B][URL="https://www.mathworks.com/matlabcentral/profile/authors/136425-loren-shure?s_tid=blg_to_profile"]Loren Shure[/URL][/B], July 30, 2019 Do your kids have to practice solving mathematical word problems? Maybe they need to practice more during school breaks? I've written a function that can turn you in to a machine for torturing your kids with some. Actually, this started off as a tool to find the date on which I was X times older than a colleague. It's super simple to do this with the help of the [URL="https://www.mathworks.com/help/matlab/ref/datetime.html"]datetime[/URL] datatype in MATLAB. [B]Contents[/B] [LIST][*][URL="https://blogs.mathworks.com/loren/2019/07/30/mathematical-word-problems-construction-tool/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+mathworks%2Floren+%28Loren+on+the+Art+of+MATLAB%29#c775f5fe-6747-4f46-8012-3f316c052990"]How does it work?[/URL][*][URL="https://blogs.mathworks.com/loren/2019/07/30/mathematical-word-problems-construction-tool/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+mathworks%2Floren+%28Loren+on+the+Art+of+MATLAB%29#460c17aa-18b6-4097-9f48-2a305e6e33d1"]Vectorizing[/URL][*][URL="https://blogs.mathworks.com/loren/2019/07/30/mathematical-word-problems-construction-tool/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+mathworks%2Floren+%28Loren+on+the+Art+of+MATLAB%29#43950e5f-4853-4e5a-84fa-3d2bf70e6fc3"]And Then I Realized...[/URL][*][URL="https://blogs.mathworks.com/loren/2019/07/30/mathematical-word-problems-construction-tool/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+mathworks%2Floren+%28Loren+on+the+Art+of+MATLAB%29#e0ed0b99-9dab-48a8-9b4d-676831438503"]Improvements to Be Made[/URL][*][URL="https://blogs.mathworks.com/loren/2019/07/30/mathematical-word-problems-construction-tool/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+mathworks%2Floren+%28Loren+on+the+Art+of+MATLAB%29#f745b186-1c8d-48e0-8729-371eb61c47b9"]Seriously...[/URL][*][URL="https://blogs.mathworks.com/loren/2019/07/30/mathematical-word-problems-construction-tool/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+mathworks%2Floren+%28Loren+on+the+Art+of+MATLAB%29#1f3ec82c-7c1b-4a82-85ee-3193ade2d13a"]The Function ntupleday[/URL][/LIST][B]How does it work?[/B] Given the birthdates for the elder and younger person, we want to return the date on which the elder is N times older than the younger one. Let's try it. elderdate = datetime(1950, 1, 1);youngerdate = datetime(1992, 7, 17);doubledate = ntupleday(2, elderdate, youngerdate)From there, it's just a matter of creating the relationships between various people, basically a set of linear constraints, and you are ready to embellish the stories as a new torture device for your kids. problems with for your kids to solve. [B]Vectorizing[/B] It was super easy to vectorize this, with respect to dates. dd = datetime(1950, 1, 1:3:28)';yd = datetime(1992, 7, 17:3:44)';nd = ntupleday(2,dd,yd)nd = 10×1 datetime array 31-Jan-2035 03-Feb-2035 06-Feb-2035 09-Feb-2035 12-Feb-2035 15-Feb-2035 18-Feb-2035 21-Feb-2035 24-Feb-2035 27-Feb-2035Or for the multipliers multiplier = 1.5:0.5:4.5;newdates = ntupleday(multiplier, elderdate, youngerdate);newdates'ans = 7×1 datetime array 16-Aug-2077 31-Jan-2035 25-Nov-2020 24-Oct-2013 23-Jul-2009 21-Sep-2006 11-Sep-2004What's the trend? plot(newdates,multiplier, "-*")ylabel("Age Multiplier")xlabel("Date") [IMG]https://blogs.mathworks.com/images/loren/2019/ntupledate_01.png[/IMG] Clearly, we can't expect the younger person to actually catch up in age to the older one - just likely that the difference gets less significant over time. [B]And Then I Realized...[/B] I then realized there was nothing so special with dates except the format. So this can also be used for entities with other units, if you need to work that in. [B]Improvements to Be Made[/B] It would be great to add the full functionality for building the problems. I leave that as an exercise for you. E.g., what functions should I add if I want to be able to construct a problem given one date, say the elder, and have it spit out what the birthdate would if the child was 3 years and 2 months younger than half dad's birthdate. [B]Seriously...[/B] Do you take advantage of datetime in MATLAB? Especially if you have something novel you are doing with it, please share your thoughts [URL="https://blogs.mathworks.com/loren/?p=3402#respond"]here[/URL]. [B]The Function ntupleday[/B] function ndate = ntupleday(n, bdelder, bdyounger)ndate = bdyounger + (bdyounger-bdelder)./(n-1);if isa(bdelder, "datetime") ndate.Format = bdelder.Format;endend doubledate = datetime 31-Jan-2035 Get the MATLAB code Published with MATLAB® R2019a [url=http://feedproxy.google.com/~r/mathworks/loren/~3/37ChY4Z0aSk/]更多...[/url] |
所有时间均为北京时间。现在的时间是 23:24。 |
Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.