I did not got the required result??? error!!!
Show older comments

my programme is not upto mark,where i doing mistake help me little.thank you
4 Comments
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.
Abu Zar
on 21 Feb 2023
Abu Zar
on 21 Feb 2023
Answers (0)
Categories
Find more on Quantum Computing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!