Converts a string into a function to plot
Mostra commenti meno recenti
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 Commenti
"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
il 4 Set 2020
Risposta accettata
Più risposte (1)
KSSV
il 4 Set 2020
equ=sin(x);
f= @(x) equ;
x = linspace(0,2*pi) ;
plot(x,f(x))
Categorie
Scopri di più su Title in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

