derivative plot of function
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
function y=f(p,t)
ea=2.25;
em=0.15+1i*3.2;
theta=1:15;
x=1.5*sin(theta);
ka=sqrt(ea-x.^2);
km=sqrt(em-x.^2);
y=2.*atan(1i.*(1-exp(2*1i.*km.*p))./(1+exp(2*1i.*km.*p)))-2.*atan(1i.*exp(2*1i.*ka.*t)./(1+exp(2*1i.*ka.*t)));
end
when we take p=1:15
plot dy/dt vs p and plot dy/dt /dy/dp vs p
2 comentarios
Geoff Hayes
el 21 de En. de 2022
@shiv gaur - please clarify your question. Are you asking how to determine the derivative of the function with respect to t?
Respuestas (1)
Vidhi Agarwal
el 27 de Nov. de 2024
To determine the derivative of the function ( y = f(p, t) ) with respect to ( t ), try using "symbolic differentiation" in MATLAB.
Below are the steps that might help you out to derivative of the function and plot it:
- Use symbolic variables for ( p ), ( t ), and any other parameters that might affect the differentiation.
- Use the "diff" function to compute the derivative with respect to ( t ).
- Evaluate the derivative at specific values of ( p ), ( t ), or other parameters.
Sample code is given below:
% Initialize arrays to store evaluated values
p_values = 1:15;
dy_dt_values = zeros(size(p_values));
dy_dp_values = zeros(size(p_values));
% Evaluate the derivatives over the range p = 1:15
t_value = 0.5; % Example value for t
for i = 1:length(p_values)
dy_dt_sum = 0;
dy_dp_sum = 0;
for j = 1:length(theta)
% Evaluate dy/dt and dy/dp for each theta
dy_dt_j = diff(y(p, t, ka(j), km(j)), t);
dy_dp_j = diff(y(p, t, ka(j), km(j)), p);
% Substitute specific values and sum the contributions
dy_dt_sum = dy_dt_sum + double(subs(dy_dt_j, {p, t}, {p_values(i), t_value}));
dy_dp_sum = dy_dp_sum + double(subs(dy_dp_j, {p, t}, {p_values(i), t_value}));
end
% Store the averaged results
dy_dt_values(i) = dy_dt_sum / length(theta);
dy_dp_values(i) = dy_dp_sum / length(theta);
end
To read more about "Symbolic Math Toolbox" and "diff" refer to the following documentation:
- Symbolic Math Toolbox : https://www.mathworks.com/help/releases/R2021b/symbolic
- diff: https://www.mathworks.com/help/releases/R2021b/matlab/ref/diff.html
Hope this helps!
0 comentarios
Ver también
Categorías
Más información sobre Symbolic Math Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!