Why is the a vector not getting added to constants?
2 views (last 30 days)
Show older comments
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 Comments
Athulya Thulaseedharan
on 9 May 2023
Edited: Athulya Thulaseedharan
on 10 May 2023
Walter Roberson
on 10 May 2023
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.
Answers (1)
Prateekshya
on 16 Aug 2023
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.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!