how can i plot this code ?

1 view (last 30 days)
Tomer Segev
Tomer Segev on 30 Sep 2020
Commented: Rik on 1 Oct 2020
hey, I want to plot this code the ri veriable is a scalar and not a vector, also how can I define Z1 and Z2 without the operator @ ?
s= [0,5*10^-2,1*10^-1,1.5*10^-1,2*10^-1,2.5*10^-1,3*10^-1,3.5*10^-1,4*10^-1,4.5*10^-1,5*10^-1,5.5*10^-1,6*10^-1,6.5*10^-1,7*10^-1,7.5*10^-1,8*10^-1,8.5*10^-1,9*10^-1,9.5*10^-1,9.9*10^-1,9.99*10^-1,1,1,1,1,1];
omega= [3.74*10^-1, 3.8*10^-1,3.87*10^-1,3.94*10^-1,4.02*10^-1,4.11*10^-1,4.2*10^-1,4.29*10^-1,4.4*10^-1,4.51*10^-1,4.64*10^-1,4.78*10^-1,4.94*10^-1,5.12*10^-1,5.33*10^-1,5.57*10^-1,5.86*10^-1,6.23*10^-1,6.72*10^-1,7.46*10^-1,8.71*10^-1,9.56*10^-1,9.68*10^-1,9.72*10^-1,9.75*10^-1,9.8*10^-1,9.86*10^-1];
plot(s,omega,'.');
hold on
Z1=@(s) (1+ ((1-s.^2)^(1/3))*((1+s).^1/3+(1-s).^1/3));
Z2=@(s,Z1) ((3*s.^2+Z1.^2).^1/2);
p=2;
w=3;
c= 3*10^8;
G=6.67384*10^-11;
M=1;
ri= (G*M./c^2).*(3.+Z2+sqrt(9+6.*Z2-(Z1).^2-2*(Z2.*Z1)));
plot(ri,omega,'r');

Answers (1)

Alan Stevens
Alan Stevens on 30 Sep 2020
You need to plot them separately as they have completely different 'x' values (indeed the ri values seem unbelievably small!):
s= [0,5*10^-2,1*10^-1,1.5*10^-1,2*10^-1,2.5*10^-1,3*10^-1,3.5*10^-1,4*10^-1,4.5*10^-1,5*10^-1,5.5*10^-1,6*10^-1,6.5*10^-1,7*10^-1,7.5*10^-1,8*10^-1,8.5*10^-1,9*10^-1,9.5*10^-1,9.9*10^-1,9.99*10^-1,1,1,1,1,1];
omega= [3.74*10^-1, 3.8*10^-1,3.87*10^-1,3.94*10^-1,4.02*10^-1,4.11*10^-1,4.2*10^-1,4.29*10^-1,4.4*10^-1,4.51*10^-1,4.64*10^-1,4.78*10^-1,4.94*10^-1,5.12*10^-1,5.33*10^-1,5.57*10^-1,5.86*10^-1,6.23*10^-1,6.72*10^-1,7.46*10^-1,8.71*10^-1,9.56*10^-1,9.68*10^-1,9.72*10^-1,9.75*10^-1,9.8*10^-1,9.86*10^-1];
Z1= (1+ ((1-s.^2).^(1/3)).*((1+s).^1/3+(1-s).^1/3));
Z2= ((3*s.^2+Z1.^2).^1/2);
p=2;
w=3;
c= 3*10^8;
G=6.67384*10^-11;
M=1;
ri= (G*M./c^2).*(3.+Z2+sqrt(9+6.*Z2-(Z1).^2-2*(Z2.*Z1)));
subplot(2,1,1);
plot(s,omega,'.');
xlabel('s'),ylabel('omega')
subplot(2,1,2)
plot(ri,omega,'r');
xlabel('ri'),ylabel('omega')
  1 Comment
Rik
Rik on 1 Oct 2020
Comment posted as answer by Tomer Segev:
Hey, thank you for your help!

Sign in to comment.

Categories

Find more on 2-D and 3-D 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!