how to plot the drivative ?

1 visualización (últimos 30 días)
Tomer Segev
Tomer Segev el 8 de Oct. de 2020
Editada: Karan Singh el 2 de Feb. de 2025
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= sqrt(3*(s.^2)+(Z1.^2));
Ri= 3+Z2-sqrt((3-Z1).*(3+Z1+2.*Z2));R= 3+Z2+(sqrt((3-Z1).*(3+Z1+2.*Z2)));
Wi= (s+((Ri).^(3/2))).^-1;
WR= (s+((R).^(3/2))).^-1;
Rlr= 2*(1+cos((2/3)*acos(-s)));
Wlr= (s+((Rlr).^2)).^-1;
plot(s,Wi,'r');
hold on
plot(s,WR,'y'),plot(s,Wlr,'b'),plot(s,omega,'g');
hold off
xlabel('spin'),ylabel('angular velocity'),legend('r-prograde Isco angular velocity','y-retrograde ISCO angular velocity','b-LR angular velocity','g-given angular velocity');
y= diff(Wi);
s=diff(s);
c=diff(omega);
plot(s,y,'r');
how can I plot this ? because it doesn't give me to plot y over s
  3 comentarios
Tomer Segev
Tomer Segev el 8 de Oct. de 2020
but s is variable that goes to one, and here it goes just until 0.05
VBBV
VBBV el 9 de Oct. de 2020
Editada: VBBV el 9 de Oct. de 2020
you are using hold off in your program. So its plotting only the last figure. Use the legend function in the last line preferably to match the variables. You are taking the diff of the vector s . The max value in s is 0.05
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,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,9.92*10^-1];
Z1= 1+((1-(s.^2)).^(1/3)).*(((1+s).^(1/3))+(1-s).^(1/3));
Z2= sqrt(3*(s.^2)+(Z1.^2));
Ri= 3+Z2-sqrt((3-Z1).*(3+Z1+2.*Z2));R= 3+Z2+(sqrt((3-Z1).*(3+Z1+2.*Z2)));
Wi= (s+((Ri).^(3/2))).^-1;
WR= (s+((R).^(3/2))).^-1;
Rlr= 2*(1+cos((2/3)*acos(-s)));
Wlr= (s+((Rlr).^2)).^-1;
plot(s,Wi,'r');
hold on
plot(s,WR,'y'),plot(s,Wlr,'b'),plot(s,omega,'g');
hold on
xlabel('spin'),ylabel('angular velocity'),legend('r-prograde Isco angular velocity','y-retrograde ISCO angular velocity','b-LR angular velocity','g-given angular velocity');
y= diff(Wi);
s=diff(s);
c=diff(omega);
plot(s,y,'r');

Iniciar sesión para comentar.

Respuestas (1)

Karan Singh
Karan Singh el 2 de Feb. de 2025
Editada: Karan Singh el 2 de Feb. de 2025
I think you are incorrectly reassigns s to diff(s), which causes issues because s is no longer the original x-axis values.The derivative is not computed correctly because y is just the difference in Wi, not the actual derivative (dWi/ds). Also the derivative plot was attempted in the same figure as the original data.
Here is my attempt for you to check.
s = [0,5e-2,1e-1,1.5e-1,2e-1,2.5e-1,3e-1,3.5e-1,4e-1,4.5e-1,5e-1,5.5e-1,6e-1,6.5e-1,7e-1,7.5e-1,8e-1,8.5e-1,9e-1,9.5e-1,9.9e-1,9.99e-1,1,1,1,1,1];
omega = [3.74e-1,3.8e-1,3.87e-1,3.94e-1,4.02e-1,4.11e-1,4.2e-1,4.29e-1,4.4e-1,4.51e-1,4.64e-1,4.78e-1,4.94e-1,5.12e-1,5.33e-1,5.57e-1,5.86e-1,6.23e-1,6.72e-1,7.46e-1,8.71e-1,9.56e-1,9.68e-1,9.72e-1,9.75e-1,9.8e-1,9.86e-1];
Z1 = 1 + ((1 - (s.^2)).^(1/3)) .* (((1 + s).^(1/3)) + (1 - s).^(1/3));
Z2 = sqrt(3 * (s.^2) + (Z1.^2));
Ri = 3 + Z2 - sqrt((3 - Z1) .* (3 + Z1 + 2 .* Z2));
R = 3 + Z2 + sqrt((3 - Z1) .* (3 + Z1 + 2 .* Z2));
Wi = (s + ((Ri).^(3/2))).^-1;
WR = (s + ((R).^(3/2))).^-1;
Rlr = 2 * (1 + cos((2/3) * acos(-s)));
Wlr = (s + ((Rlr).^2)).^-1;
figure;
plot(s, Wi, 'r');
hold on;
plot(s, WR, 'y');
plot(s, Wlr, 'b');
plot(s, omega, 'g');
hold off;
xlabel('spin');
ylabel('angular velocity');
legend('r-prograde ISCO angular velocity', 'y-retrograde ISCO angular velocity', 'b-LR angular velocity', 'g-given angular velocity');
% Compute the derivative of Wi with respect to s
dWi = diff(Wi); % Differences in Wi
ds = diff(s); % Differences in s
derivative_Wi = dWi ./ ds; % Derivative of Wi
figure;
plot(s(1:end-1), derivative_Wi, 'r');
xlabel('spin');
ylabel('d(Wi)/ds');
title('Derivative of Wi with respect to s');

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by