Plotting a function with vectors that show propagation of function.
2 views (last 30 days)
Show older comments
I want to plot the following fisure with arrows that denote the progation of function.
the valirable is z which goes from to ∞ for the sake of convience I am taking range from -150 to 150.
θ is a function of z which from which we get θ as to .
clear all;
clc;
close all;
z = linspace(-150,150,10000);
pi = 3.1415;
% theta = linspace(-pi/2,pi/2,100);
% z = linspace(-pi/2,pi/2,100);
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));
u = sqrt(g2*sigma0+2*g3*sigma0);
sigma = sigma0*(1-(B./(1+D.*z.^2)));
theta = -(u*B/(sqrt(1-B)*D)).*atan(sqrt(D./(1-B)).*z);
psi = sqrt(sigma).*(cos(theta)+1i.*sin(theta));
figure(1)
plot3(theta,imag(psi),real(psi));
hold on
plot3(theta, real(psi), zeros(size(theta))-0.5)
plot3(theta, zeros(size(theta))-0.5, imag(psi))
hold off
grid on
xlabel('\theta')
ylabel('Real Part')
zlabel('Imgainary Part')
figure(2)
plot(z,theta);
grid on
xlabel('z')
ylabel('\theta')
the plot I get is this
I want to the plot to look like
I tried using command quiver3(z,theta,imag(psi),real(psi)) but no fruitful results.
What changes will I have to make in my code?
0 Comments
Answers (1)
Alan Stevens
on 8 Aug 2020
Does this do what you want:
X = linspace(-150,150,200);
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));
u = sqrt(g2*sigma0+2*g3*sigma0);
sigma = sigma0*(1-(B./(1+D.*X.^2)));
theta = -(u*B/(sqrt(1-B)*D)).*atan(sqrt(D./(1-B)).*X);
psi = sqrt(sigma).*(cos(theta)+1i.*sin(theta));
Y = zeros(size(X)); Z = zeros(size(X));
U = zeros(size(psi)); V = real(psi); W = imag(psi);
figure(1)
quiver3(X, Y, Z, U, V, W);
axis([-150 150 -20 20 -20 20])
0 Comments
See Also
Categories
Find more on Surface and Mesh Plots 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!