Link to home
Start Free TrialLog in
Avatar of crossratio
crossratio

asked on

Strings and functions

How can I write a function that would compute an inputed string like 'five times (four plus seven)'? I want it to recognize that five=5, four=4, and seven=7 and compute the operations as matlab normally would. i guess i'm just confused on how to deal with the string in general. any help would be greatly appreciated. thank you in advance
ASKER CERTIFIED SOLUTION
Avatar of yuk99
yuk99
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of TommySzalapski
TommySzalapski
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of crossratio
crossratio

ASKER

Thanks so much! I was thinking about using strtok, so this seems logical and makes sense.
@crossratio: Why don't you like my solution? Have you tried it? Do you underdtand how it work? This is more matlabish way to use regular expressions and mapping cell arrays that can be imported from a file or db. And it's scalable.
I'm guessing she actually needs to parse the string for some reason. (Class? Learning string stuff?) So your solution may have been too good. cross, if you didn't see yuk's first post, MATLAB basically has your function built in (which I didn't know). If that was what you actually wanted you should hit 'request attention' and give him the points instead. If you did want to actually parse the string yourself, then all is well.
Yes, actually i wanted to parse the string myself. Thank you too you both though. yuk, your answer is also great and useful to know.