Error using fprintf Unable to convert 'sym' value to 'double'.
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Sila Fundora
el 30 de Sept. de 2020
Comentada: Star Strider
el 7 de Oct. de 2020
I am new in Matlab, and basically it seems I am not using the symbolic variables correctly.
t=0:0.5:10;sm x ;
R=zeros(1,length(t),'sym');
for ii=1:length(t)
f=tanh(x)^2/(x^2)*cos((x*tanh(x))^(1/2)*t(ii));
R(ii)=(2/pi)* int(f,x,0,inf);
fprintf('%2.1f\t %3.10f\n',[t(ii); R(ii)])
end
0 comentarios
Respuesta aceptada
Star Strider
el 30 de Sept. de 2020
This works (with the fprintf call corrected to eliminate the spaces between the backslant and the characters they escape, and a few other corrections):
t = 0: 0.5: 10;
syms x;
R = zeros (1, length (t),'sym');
for ii = 1: length (t)
f = tanh (x) ^ 2 / (x ^ 2) * cos ((x * tanh (x)) ^ (1/2) * t (ii));
R (ii) = (2 / pi) * vpaintegral (f, x, 0, inf);
fprintf ('% 2.1f \t% 3.10f \n', [t (ii); R (ii)])
end
.
6 comentarios
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
