필터 지우기
필터 지우기

Need help solving and plotting a first order pde

조회 수: 2 (최근 30일)
Namit Dayal
Namit Dayal 2023년 10월 30일
댓글: Sam Chak 2023년 11월 17일
I've tried using ode45 however the values for tau come out to be negative which shouldn't be possible
I need to plot tau vs gamma
The code for the same :
clc, clearvars, close all
eta0 = 8080;
lambda = 1.109;
gamma = logspace(-3, 3, 100);
f = @(t, tau) (-(tau + eta0 * interp1(linspace(0, 100, length(gamma)), gamma, t)) / lambda);
[t, tau] = ode45(f, [0, 100], 0);
gammaint = interp1(linspace(0, 100, length(gamma)), gamma, t);
loglog(tau,gammaint,'.')
  댓글 수: 6
Torsten
Torsten 2023년 10월 30일
편집: Torsten 2023년 10월 30일
But the equation says gamma_dot ... Thus you will have to differentiate gamma before you put it in your equation, haven't you ?
gamma = logspace(-3,3,100);
gamma_dot(1) = (gamma(2)-gamma(1));
for i = 2:numel(gamma)-1
gamma_dot(i) = (gamma(i+1)-gamma(i-1))/2;
end
gamma_dot(end+1) = gamma(end)-gamma(end-1);
hold on
plot(gamma)
plot(gamma_dot)
hold off
grid on
Sam Chak
Sam Chak 2023년 11월 17일
Your question looks identical to this one. Can we merge them? If they are not the same, could you please resolve one of them before moving on to the other?

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

답변 (1개)

Walter Roberson
Walter Roberson 2023년 10월 30일
You have the derivative of tau with respect to t, so tau is a function of t.
You wish to plot tau vs gamma, so tau is also a function of gamma.
When you have something that is a function of two variables, then you have a PDE rather than an ODE. ode45 and the other ode* functions are only for ODE.
You appear to have as in the derivative of gamma, so this appears to have two derivatives -- but you only have one equation. To solve you need as many equations as the sum of the highest derivative order for each variable. First derivative for gamma plus first derivative for tau --> 1 + 1 = 2 so you need two equations.
  댓글 수: 1
Walter Roberson
Walter Roberson 2023년 10월 30일
이동: Walter Roberson 2023년 10월 30일
syms tau(t) lambda_1 eta_0 gamma__dot
tau__dot = diff(tau);
ode = tau + lambda_1 * tau__dot == - eta_0 * gamma__dot
ode(t) = 
sol = dsolve(ode)
sol = 
Assuming positive lambda_1, the larger t gets, the more the exp() goes to 0 so the more the C_1 term goes to 0. Subtract off the other term and you can certainly go negative. The only way to prevent that is negative lambda_1 or negative product of (eta_0 and gamma__dot) so that you are adding a value instead of subtracting.

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

태그

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by