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')
  댓글 수: 1
Rik
Rik 2020년 10월 1일
Comment posted as answer by Tomer Segev:
Hey, thank you for your help!

댓글을 달려면 로그인하십시오.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by