derivative plot of function

8 ビュー (過去 30 日間)
shiv gaur
shiv gaur 2022 年 1 月 21 日
回答済み: Vidhi Agarwal 2024 年 11 月 27 日
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 件のコメント
Geoff Hayes
Geoff Hayes 2022 年 1 月 21 日
@shiv gaur - please clarify your question. Are you asking how to determine the derivative of the function with respect to t?
shiv gaur
shiv gaur 2022 年 1 月 21 日
yes

サインインしてコメントする。

回答 (1 件)

Vidhi Agarwal
Vidhi Agarwal 2024 年 11 月 27 日
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!

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

タグ

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by