why MATLAB is busy for this code?

2 ビュー (過去 30 日間)
Abu Zar
Abu Zar 2023 年 1 月 15 日
コメント済み: Abu Zar 2023 年 1 月 15 日
1.What is the result?
creation=circshift(diag(sqrt(0:1:14)),-1);
annihilation=creation';
syms n
alpha = sym(0.03);
ketalpha1 = symsum(exp(-abs(alpha)^2 * alpha^n / sqrt(factorial(n)) ), n, 0, 14);
syms n
alpha = sym(0.06);
ketalpha2 = symsum(exp(-abs(alpha)^2 * alpha^n / sqrt(factorial(n)) ), n, 0, 14);
syms n
alpha = sym(0.09);
ketalpha3 = symsum(exp(-abs(alpha)^2 * alpha^n / sqrt(factorial(n)) ), n, 0, 14);
syms n
alpha = sym(0.12);
ketalpha4 = symsum(exp(-abs(alpha)^2 * alpha^n / sqrt(factorial(n)) ), n, 0, 14);
syms n
alpha = sym(0.15);
ketalpha5 = symsum(exp(-abs(alpha)^2 * alpha^n / sqrt(factorial(n)) ), n, 0, 14);
syms n
alpha = sym(0.18);
ketalpha6 = symsum(exp(-abs(alpha)^2 * alpha^n / sqrt(factorial(n)) ), n, 0, 14);
V1=annihilation*ketalpha1-0.03*ketalpha1;
V2=annihilation*ketalpha2-0.06*ketalpha2;
V3=annihilation*ketalpha3-0.09*ketalpha3;
V4=annihilation*ketalpha4-0.12*ketalpha4;
V5=annihilation*ketalpha5-0.15*ketalpha5;
V6=annihilation*ketalpha5-0.18*ketalpha5;
Vnorm1=V1'*V1;
Vnorm2=V2'*V2;
Vnorm3=V3'*V3;
Vnorm4=V4'*V4;
Vnorm5=V5'*V5;
Vnorm6=V6'*V6;
alpha=[0.03;0.06;0.09;0.12;0.15;0.18];
Vnorm=[Vnorm1;Vnorm2;Vnorm3;Vnorm4;Vnorm5;Vnorm6];
size(alpha)
ans = 1×2
6 1
size(Vnorm)
ans = 1×2
90 15
plot(alpha,Vnorm)
Error using plot
Vectors must be the same length.
xlabel('alpha','FontSize',12,'FontWeight','bold')
ylabel('Vnorm','FontSize',12,'FontWeight','bold')
  2 件のコメント
Torsten
Torsten 2023 年 1 月 15 日
As you can see, alpha has dimension 6x1 and Vnorm has dimension 90x15.
How to plot Vnorm against alpha ?
Abu Zar
Abu Zar 2023 年 1 月 15 日
Thank you 🌹

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2023 年 1 月 15 日
My tests show it executing quickly but failing the plot.
annihilation is 15x15 so your Vnorm variables are 15x15. You [] 6 of those together to get 90 x 15 but expect to be able to plot that against 6 alpha values.
annihilation is created by a diag() so it is not going to be a vector.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeParticle & Nuclear Physics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by