Graphing exponential function with imaginary term

조회 수: 1 (최근 30일)
Nachiket Kortikar
Nachiket Kortikar 2020년 8월 3일
댓글: Nachiket Kortikar 2020년 8월 8일
I am trying to plot a function where my amplitude is dependant on varaiable say z. and the phase is depentant on theta which is varying form -pi/2 to pi/2.
I get error as
empty double row vector
I saw some other plots. I don't understnd why it doens't work for me.
clear all;
clc;
close all;
pi = 3.1415;
theta = linspace(-pi/2,pi/2,0.01)
z = linspace(-pi/2,pi/2,0.01)
g2 = 5;
g3 = 0.5;
sigma0 = 0.05;
B = -(3*g2*sigma0-8*g3*sigma0)/((2*g2*sigma0))
D = (3*g2*sigma0-8*g3*sigma0)^2/((6*g2))
sigma0 = 0.05;
sigma = sigma0*(1-(B./(1+D.*z.^2)))
psi = sqrt(sigma).*exp(1i.*theta)
figure()
plot3(theta,real(psi),imag(psi))
% plot3(z,theta,imag(psi))
% hold on
grid on
xlabel('\psi', 'Rotation',-30)
ylabel('Real Axis', 'Rotation',10)
zlabel('Imag Axis')

채택된 답변

Cris LaPierre
Cris LaPierre 2020년 8월 3일
I suspect it has to do with how you define theta and z. Check out the documentation for linspace. The last number is the nubmer of data points you want. You have asked for 0.01, which is not possible, so theta and z are both empty vectors.
theta = linspace(-pi/2,pi/2,300);
z = linspace(-pi/2,pi/2,300);
If you want a specific increment, use the colon operator instead
theta = -pi/2:0.01:pi/2;
z = -pi/2:0.01:pi/2;

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by