I did not got the required result??? error!!!

my programme is not upto mark,where i doing mistake help me little.thank you

4 Commenti

I am not able to edit this question. Maybe the image is too huge. Please shrink and rotate it to improve the readability. Posting code directly is useful also:
D = 15;
tmpI = eye(D);
%sum of ket1 to ket14 is
%generalised this line of code for any value of D
ket = sum(tmpI(:,2:D),2);
syms n
ct = 6;
creation = circshift(diag(sqrt(0:1:(D-1))),-1);
annihilation = creation';
%pre-allocation
%[ketalpha, V, Vnorm] = deal(cell(1,ct));
Vnorm = zeros(1,ct);
alpha = 0.03*(1:ct);
%loop for calculation
for k = 1:ct
temp0 = symsum(exp(-abs(alpha(k))^2 * alpha(k)^n / sqrt(factorial(n)) ), n, 0, 14)*ket;
%ketalpha{k} = temp0;
temp1 = annihilation*temp0 - alpha(k)*temp0;
%V{k} = temp1;
Vnorm(k) = temp1'*temp1;
end
plot(alpha,Vnorm, '-*k')
xlim([0 0.21])
xlabel('alpha', 'Color', 'b', 'FontSize', 15)
ylabel('Vnorm', 'Color', 'b', 'FontSize', 15)
It runs without an error. I you do get an error, post a copy of the complete message.
hi,thank you it is fine.
please help me to put follow this message in these codes ;
---->Temp0 is a sum from n=0 to n=14. try the following and find the result, please.
for n=0:14
temp0 =temp0+ double(symsum(exp(-0.5*abs(alpha(k))^2)* alpha(k)^n / sqrt(factorial(n)), n, 0, 14)*ket);
end
Thank you
@Abu Zar: Ist there a problem with the posted code? If so, which one?

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Quantum Computing in Centro assistenza e File Exchange

Richiesto:

il 20 Feb 2023

Commentato:

Jan
il 21 Feb 2023

Community Treasure Hunt

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

Start Hunting!

Translated by