Why is the a vector not getting added to constants?

2 ビュー (過去 30 日間)
Athulya Thulaseedharan
Athulya Thulaseedharan 2023 年 5 月 9 日
回答済み: Prateekshya 2023 年 8 月 16 日
I have a vector omega with 110 elements. I am trying to calculate D1. alpha and detun are constants.
While I add the constant term to the third term that containes omega^2, I am getting D1 as an array with 110 elements that corresponds to (-alpha/2 - 1i*detun). It seems like the third term with omega.^2 is not coming to the calculation. Can someone comment on why I have this issue?
D1 = -alpha/2 - 1i*detun + 1i*s*omega.^2;
  4 件のコメント
Athulya Thulaseedharan
Athulya Thulaseedharan 2023 年 5 月 9 日
編集済み: Athulya Thulaseedharan 2023 年 5 月 10 日
Hi John,
Here are the values for s, detun and the omega.
s=-1;
detun = 1e-4;
alpha=140;
nT = 110; T = 3;
omega = fftshift((2*pi/T)*(-nT/2:nT/2-1));
D1 = -alpha/2 - 1i*detun + 1i*s*omega.^2;
After running the code I get a vector ( -70.0000 - 0.0001i repeated 110 times, which corresponds to (-alpha/2 - 1i*detun). I tried to debug but could't find any solutionto this issue.
Walter Roberson
Walter Roberson 2023 年 5 月 10 日
s=-1;
detun = 1e-4;
alpha=140;
nT = 110; T = 3;
omega = fftshift((2*pi/T)*(-nT/2:nT/2-1));
D1 = -alpha/2 - 1i*detun + 1i*s*omega.^2;
plot(real(D1), 'k-');
hold on
plot(imag(D1), 'b-');
hold off
The values differ for sure.

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

回答 (1 件)

Prateekshya
Prateekshya 2023 年 8 月 16 日
I understand that you can see a vector of repeated numbers which is incorrect. Assuming that you have executed the same code that you have provided in the comment section, I added a few more lines to see the first five elements individually. The code that I executed is given below:
s=-1;
detun = 1e-4;
alpha=140;
nT = 110; T = 3;
omega = fftshift((2*pi/T)*(-nT/2:nT/2-1));
D1 = -alpha/2 - 1i*detun + 1i*s*omega.^2;
D1(1)
D1(2)
D1(3)
D1(4)
D1(5)
Here are the values printed in the command window:
-70.0000 - 0.0001i
-70.0000 - 4.3866i
-70.0000 -17.5461i
-70.0000 -39.4785i
-70.0000 -70.1840i
Hence, "omega" is included in the calculation. You can also look at the plot given in the comment. You can also verify if the code that you are executing is same as the one you have provided here in comments.

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by