how can i plot this code ?

2 次查看(过去 30 天)
Tomer Segev
Tomer Segev 2020-9-30
评论: Rik 2020-10-1
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');

回答(1 个)

Alan Stevens
Alan Stevens 2020-9-30
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')

类别

Help CenterFile Exchange 中查找有关 Graphics 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by