sym/double error(line 665)
18 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
syms x y
% microstructured equation
%g(x, y) = (2-3*cos(x)+cos(x).^3 + 2-3*cos(y)+cos(y).^3);
freq = 10^5; % Frequncy
geometrical_area = (1/freq)^2;
A = 10^-6; % Amplitude
g(x, y) = A*sin(2*pi*freq*x)+A*sin(2*pi*freq*y);
g_x = diff(g,x);
g_y = diff(g,y);
g_x=vpa(g_x^2);
g_y=vpa(g_y^2);
G = sqrt(1 + g_x + g_y);vpa(G);
s = int(int(G,x,0,2*pi),y,0,2*pi); % surface area equation
S=vpa(s);
roughness_area = double(S); %symbolic to double
why this code have error??
But when the parameter is ' A=1, freq=1/ (2*pi)' , the code has not problem.....
(Error code in command window)
다음 사용 중 오류가 발생함: symengine
Unable to convert expression into double array.
오류 발생: sym/double (line 665)
Xstr = mupadmex('symobj::double', S.s, 0);
what is it mean that error code?
2 Commenti
Alok Nimrani
il 18 Feb 2019
The reason for this error is that 'S' is an expression and double function can convert only the symbolic values into double as mentioned here.
You will have to evaluate the expression first to obtain a symbolic value and then convert the symbolic value into a double. Are there any particular values of x and y for which you want to get the double value? In that case, you can assign corresponding values to symbolic variables x and y and then make use of subs function to evaluate the expressions at each stage.
Walter Roberson
il 18 Feb 2019
The frequency is too high for matlab to be able to evaluate the integral numerically with the default error tolerances and maximum iterations
Risposte (1)
madhan ravi
il 18 Feb 2019
P.S: There is a warning at the end but yields a result without error
G = matlabFunction(sqrt(1 + g_x + g_y)); % read about matlabFunction()
s = integral2(G,0,2*pi,0,2*pi); % surface area equation
0 Commenti
Vedere anche
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!