Plotting infinite series with set of parameters

I want to plot the following functions,
Here, and given by
is a set of values of values given by,
I have approximated a set of values for . I have tried the following code, but failed to generate expected plot. Is that due to approximation, or there is any other error in my code?
clc
clear all
syms Y
k = 0.1;
j=[-8.0671,-5.30732,-2.62768,0,8.0671,5.30732,2.62768];
for i=1:length(j)
f1 = (sin(j(i))+ k*j(i)*cos(j(i)))*cos(j(i)*Y) - (cos(j(i)) - k*j(i)*sin(j(i)))*sin(j(i)*Y);
f2=((((j(i).^4)/16)+1)*((k*(k + 1)*sin(j(i))) - (1 + 2*k - k^.2*j(i).^2)*((cos(j(i)))/(2*j(i)))));
U=0.25*sum(((f1/f2)*exp(-0.25*j(i).^2)),i,1:8);
fplot(U);xlim([0 1]);%hold on;
end

3 comentarios

darova
darova el 8 de Sept. de 2019
Maybe it's a bit complicated for symbolic function fplot()?
Did you try to plot numerically?
What about . Where is τ? Is it 2D plot (surface)?
Moslem Uddin
Moslem Uddin el 8 de Sept. de 2019
I have considered $\tau=1$
Moslem Uddin
Moslem Uddin el 8 de Sept. de 2019
It’s not a surface plot.

Iniciar sesión para comentar.

 Respuesta aceptada

darova
darova el 8 de Sept. de 2019

1 voto

Looks like simple sin() or cos():
export_fig_out.png export_fig_out1.png
What do you think?
Try my script, i think i reached a success

10 comentarios

Moslem Uddin
Moslem Uddin el 8 de Sept. de 2019
Thanks! your code provides solution very close to my expectation. Maybe, the discrepancy is due to approximation. Is there any way to find all values of ? is given by,
a3.PNG
darova
darova el 8 de Sept. de 2019
Editada: darova el 8 de Sept. de 2019
Try this
k = 0.1;
f = @(j) tan(j) + 2*k*j./(1-k^2*j.^2);
j0 = zeros(1,20); % find 20 roots
j0(1) = fsolve(f,0); % find first root
for i = 1:length(j0)-1
j0(i+1) = j0(i) + 3.5; % initial guess for next root
j0(i+1) = fsolve(f,j0(i+1));
end
x = linspace(0,60,500);
y = f(x);
ix = abs(y)>10; % find big numbers
y(ix) = nan; % replace big numbers with nan (better plot)
plot(x,y)
hold on
plot(j0,f(j0),'.r') % plot roots
hold off
% looks like straight line
figure
plot(j0,'.-')
Maybe some verification will be needed. For k = 0.5 not all roots are good:
EDIT: edited function
Moslem Uddin
Moslem Uddin el 8 de Sept. de 2019
How to find list of roots instead of plotting and utilise them for the above plot?
How many roots you want to find? There are infinite of them
Why not utilise?
ix = abs(f(j0))>0.01; % find if value bigger than 0.01
if sum(ix)
j1 = j0(~ix); % utilise
plot(j1,f(j1),'.-r')
end
I want find roots between -100 to 100 and want to use them in the following code given by you what to do?,
clc,clear
k = 0.1;
R = 4;
R0 = 1;
tau = 1;
y = linspace(0,2,50);
j = [-8.0671, -5.30732, -2.62768, 0, 8.0671, 5.30732, 2.62768];
[Y,J] = ndgrid(y,j);
sj = sin(J); % shortcuts
cj = cos(J);
F1 = (sj + k*J.*cj).*cos(J.*Y) - (cj - k*J.*sj).*sin(J.*Y);
F2 = (J.^4/R^2+1).* (k*(k+1).*sj - (1+2*k-J.^2*k^2).*cj/2./J);
E = R0/R * exp(-J.^2*tau/R);
U = sum(F1./F2.*E, 2); % sum along 2d dimension (j)
plot(y,U)
xlabel('Y AXIS')
ylabel('U AXIS')
darova
darova el 8 de Sept. de 2019
Read my comments in the code, they should be helpfull
And accept my answer please
Moslem Uddin
Moslem Uddin el 10 de Sept. de 2019
Thanks!
darova
darova el 10 de Sept. de 2019
Do you have a source formula? Hard to see it in the script
darova
darova el 10 de Sept. de 2019
Try to write clearer script. Hard to understand it if everything is written in one line
You forgot the dot
Also declaring y two times
11Untitled.png
Moslem Uddin
Moslem Uddin el 10 de Sept. de 2019
Thanks a lot!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Graphics Performance en Centro de ayuda y File Exchange.

Productos

Etiquetas

Preguntada:

el 8 de Sept. de 2019

Comentada:

el 10 de Sept. de 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by