Graphing exponential function with imaginary term

2 views (last 30 days)
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')

Accepted Answer

Cris LaPierre
Cris LaPierre on 3 Aug 2020
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;

More Answers (0)

Categories

Find more on Mathematics in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!