A second order mass, damper, spring system can be solved from
syms h(t) m c k h0 dh0 C10 C11
Dh=diff(h(t),t);
eqs = m*diff(h(t), t, t) == -c*Dh-k*h(t);
sol=dsolve(eqs);
h0=subs(sol,t,0);
dh0=subs(diff(sol,t),t,0);
How to rewrite the solution (sol) using the initial condtions (h0, dh0)? I am trying to determine the transition matrix, given h, dh at time 0, find the transition matrix, X, to give h, dh at later time t. I'm looking for a solution like
ic=solve({h0,dh0},{C10, C11})

댓글 수: 1

Based on Stan's answer, change the question to solve first order form, as follows
syms h(t) m c k h0 dh0 C10 C11
Dh(t)=diff(h(t),t);
eqs = m*diff(h(t), t, t) == -c*Dh-k*h(t);
% sol=dsolve(eqs, h(0)==h0, Dh(0)==dh0);
vars = [h(t)];
[eqs1st, vars1st, newVars1st] = reduceDifferentialOrder(eqs, vars);
sol1st=dsolve(eqs1st, h(0)==h0, Dh(0)==dh0 );

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

 채택된 답변

Star Strider
Star Strider 2015년 9월 14일

0 개 추천

I’m not certain what you’re asking. It’s easy enough to incorporate the initial conditions in your dsolve call, and it’s in the documentation:
syms h(t) m c k h0 dh0 C10 C11
Dh(t)=diff(h(t),t);
eqs = m*diff(h(t), t, t) == -c*Dh-k*h(t);
sol=dsolve(eqs, h(0)==h0, Dh(0)==dh0);
You can also do the integration numerically with ode45, and probably more easily, especially if you use the odeToVectorField function to create the system of first-order ODEs the numeric ODE solvers require. If you do a numeric integration, do not include the initial conditions in your differential equations. Specify them in the ode45 call instead.

댓글 수: 3

This is so close to what I want, but can you make change it to be in 1st order form. Following your example is the following, which produces an error.
syms h(t) m c k h0 dh0 C10 C11
Dh(t)=diff(h(t),t);
eqs = m*diff(h(t), t, t) == -c*Dh-k*h(t);
% sol=dsolve(eqs, h(0)==h0, Dh(0)==dh0);
vars = [h(t)];
[eqs1st, vars1st, newVars1st] = reduceDifferentialOrder(eqs, vars);
sol1st=dsolve(eqs1st, h(0)==h0, Dh(0)==dh0 );
I ended up using collect. Slightly modified example
close all; clc; clear
syms h(t) lambda omega h0 dh0
Dh(t)=diff(h(t),t);
eqs = diff(h(t), t, t) == -lambda*omega*Dh-omega*omega*h(t);
sol=dsolve(eqs, h(0)==h0, Dh(0)==dh0);
pretty(sol)
chk=simplify(diff(sol,t,t)+lambda*omega*diff(sol,t)+omega*omega*sol)
disp('sol for h')
pretty(collect(sol,{h0, dh0}))
disp('sol for dh')
pretty(collect(diff(sol,t),{h0, dh0}))
Star Strider
Star Strider 2015년 9월 14일
The odeToVectorField function should do what you want. (I use that rather than reduceDifferentialOrder.) I then use that result, sometimes with matlabFunction, to create anonymous functions to use with the numerical ODE solvers, since they will (in most instances) solve for the derivatives as well as the function.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

태그

질문:

2015년 9월 14일

댓글:

2015년 9월 14일

Community Treasure Hunt

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

Start Hunting!

Translated by