Every time I run this code, I get "Error using plot Vectors must be the same length.

3 ビュー (過去 30 日間)
beta= 50*10^-24;
z=linspace(0,100,100);
T_0= 100*10^-12;
T= linspace(-10*T_0,10*T_0,100);
U =((T_0)./sqrt(T_0^2-1i*beta*z)).*exp(-T.^2/(2*(T_0^2-1i*beta*z)));
plot3((T/T_0),U,z)
Warning: Imaginary parts of complex X, Y, and/or Z arguments ignored
xlabel('T/T_0')
ylabel('intensity')
zlabel('z')
title('gaussian pulse')
(i want this graph show in attach file)
  2 件のコメント
Walter Roberson
Walter Roberson 2024 年 11 月 15 日
The code does not generate errors about the vectors needing to be the same length.
The code does generate a warning about ignoring the imaginary parts.
If you examine U, you find that it involves sqrt(T_0^2-1i*beta*z) twice. Because of the 1i portion of the calculation, the sqrt() is going to generate complex-valued numbers. So U is going to be complex-valued.
The behavior of plot3() is to treat the code as if you had used real(U)
Aayushi
Aayushi 2024 年 11 月 15 日
Actually this is related to my phd work and it should give gaussian pulse by using same equation so what should I do for this

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

採用された回答

Walter Roberson
Walter Roberson 2024 年 11 月 15 日
The equation for guassian pulse does not involve complex numbers.

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by