Convert a string into a function of x
61 views (last 30 days)
Show older comments
Nikolas Spiliopoulos
on 21 Nov 2018
Edited: KRISHNA MAHTO
on 12 Jan 2023
Hi all,
I have created a string like this:
Sstr = join(compose('(x(%d:%d)-x(%d:%d))))', A), ' + ')
so I get a result:
Sstr='(x(2:180)-x(1:179)+(x(182:360)-x(181:359))'
Is it possible to convert the string into a function of x like this??:
f=@(x) (x(2:180)-x(1:179)+(x(182:360)-x(181:359))
thanks
Nikolas
Accepted Answer
More Answers (1)
KRISHNA MAHTO
on 12 Jan 2023
Edited: KRISHNA MAHTO
on 12 Jan 2023
i have taken string as an input form the user ,, and want data to be converted into funtion of x and y , by the program itself ,,,for easy usage ,
%code to take input form the user -
prompt = "input U:-"
u = input(prompt,"s")
prompt = "input V:-"
v = input(prompt ,"s")
0 Comments
See Also
Categories
Find more on Data Type Conversion in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!