Converts a string into a function to plot
Show older comments
So I have mathematic functions like sin(x), cos(x) etc. in a string format that I want to convert into a function so I would be able to plot it.
equ='sin(x)';
f= @(x) equ;
plot(x,f)
error message:
Error using plot
Invalid data argument.
2 Comments
"So I have mathematic functions like sin(x), cos(x) etc. in a string format that I want to convert into a function..."
Your example contains no strings or character arrays at all:
equ=sin(x);
f= @(x) equ;
This makes your question difficult to interpret. Do you actually have a character vector? E.g.:
str = 'sin';
Please show the actual definition of your input data.
iseinas
on 4 Sep 2020
Accepted Answer
More Answers (1)
Categories
Find more on Title 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!
