Converting a symbolic matrix to numeric
Mostra commenti meno recenti
Hi,
I am trying to convert a symbolic matrix to a numeric array, but am having no luck. Please refer to the code below.
Z = sym(zeros(200,1));
for i = 1:200
syms omega_n;
lambda = i*1e-7;
k_zeta = 2*pi/lambda;
kappa_n = n*pi/W;
k_n = sqrt(((kappa_n)^2) + ((k_zeta)^2))
Y(i,1) = k_n;
P_nn = (k_zeta*W)^2/(i*pi)^2;
yellow = omega_M*P_nn*(1-P_nn)*((sin(phi))^2);
green = 1 - (P_nn*(1+((cos(phi))^2)));
blue = omega_H + J*omega_M*((k_n)^2);
F_n = P_nn + green*((sin(theta))^2) + yellow/blue;
A = (sqrt(blue*(blue + (omega_M*F_n))))/(2*pi) - omega_n;
R = feval(symengine,'numeric::fsolve', A, 'omega_n=1e8')
Z(i) = vpa(omega_n);
%printf('For k = %d, freq = %d\n', k_zeta,A);
end
Y = int8(Y);
class(Z)
Z = vpa(Z,100);
class(Z)
%Z = vpa(Z);
scatter(Y,Z)
All of the variables, except for omega_n, are of type double.
When I attempt to use the 'double' function on object Z ie double(Z), I receive an error message
Error in MuPAD command: DOUBLE cannot convert the input expression into a double array. If the input expression contains a symbolic variable, use the VPA function instead.
Can someone point out where I am going wrong? This is the first time I am trying to use the symbolic toolbox, so apologies if it is something obvious! Note I am using Matlab R2011b.
Thanks!
Carl
2 Commenti
Azzi Abdelmalek
il 12 Gen 2014
You can make your question clear, by just posting the matrix you want to convert
Carl
il 12 Gen 2014
Risposte (1)
Azzi Abdelmalek
il 12 Gen 2014
Modificato: Azzi Abdelmalek
il 12 Gen 2014
0 voti
3 Commenti
Carl
il 12 Gen 2014
Azzi Abdelmalek
il 12 Gen 2014
If you post an example we can test, it will be useful
Carl
il 12 Gen 2014
Categorie
Scopri di più su Conversion 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!