Problem with summation of a function
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Here is my code:
D = 1;
w_eg = 1;
w_0 = 1;
syms k;
som = @(w)symsum(exp(-D).*D.^k.*kroneckerDelta(w - w_eg - k.*w_0)/factorial(k),k,0,100);
fplot(@(w)symsum(exp(-D).*D.^k.*kroneckerDelta(sym(w - w_eg - k.*w_0))/factorial(k),k,0,100),[0,100])
The parameters are there to change afterwords. The problem is i get wrong values, it seems like the kroneckerDelta or the summation is not working properly. I know that kroneckerDelta should get a sym as input but im not sure if i should then do
syms w - w_eg - k.*w_0;
since k is already in symbolic notation.
0 Commenti
Risposte (1)
Tarunbir Gambhir
il 28 Gen 2021
The summation is working correctly. The 'w - w_eg - k.*w_0' is a symbolic expression since it contains a symbolic variable. The reason why you are not getting the wrong values might be because of the 'Interval' and the 'MeshDensity' chosen for 'fplot'. Consider the following code for plotting your function:
D = 1;
w_eg = 1;
w_0 = 1;
syms k;
som = @(w) symsum(exp(-D).*D.^k.*kroneckerDelta(w - w_eg - k.*w_0)/factorial(k),k,0,100);
subplot(2,1,1)
fplot(som,[0.1 10],'MeshDensity',100)
title('input values: 0.1000, 0.2000, 0.3000, 0.4000, 0.5000, 0.6000...')
subplot(2,1,2)
fplot(som,[0 10],'MeshDensity',100)
title('input values: 0, 0.1010, 0.2020, 0.3030, 0.4040, 0.5051...')
It seems like the function being plotted is very sensitive to the input and thus to see the peaks you need to experiment with the 'Interval' and the 'MeshDensity'. I suggest you go through this section for more clarity.
0 Commenti
Vedere anche
Categorie
Scopri di più su Calculus in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!