Evaluate Sym values
364 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Julio Cesar
il 31 Gen 2011
Commentato: Zhe Chen
il 24 Feb 2020
Hi, I trying to make a simple program, I would like to know how to make this
syms x; fun=x^2; x0=2;
x=x0; fun
And what a expect in the last line is 4 but I get X^2 How can I convert the sym to a double, I tried with doble(fun).
thank you
0 Commenti
Risposta accettata
Più risposte (3)
Behrooz Shahsavari
il 29 Dic 2013
If you want to evaluate that symbolic function in a large number of points (e.g. x = 1:10000), an effective way is to convert it to a MATLAB function handle as follows:
x0 = 1:10000; % Assume that we want to evaluate the function in these points
FUN = matlabFunction(fun); % This creates a function handle
y = feval(FUN, x0); % Evaluates the new function handle at the specified points
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!