Converts a string into a function to plot
Ältere Kommentare anzeigen
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 Kommentare
"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
am 4 Sep. 2020
Akzeptierte Antwort
Weitere Antworten (1)
KSSV
am 4 Sep. 2020
equ=sin(x);
f= @(x) equ;
x = linspace(0,2*pi) ;
plot(x,f(x))
Kategorien
Mehr zu Title finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

