Solving a pair of equation using matlab
이전 댓글 표시
how to solve the following pair of equation using MATLAB
y(t) = k*exp(-t/2)*cos(theta + (3^(1/2)*t)/2)
y(t = 0) = 0
Dy(t = 0) = 1
Solve for "k" and "theta"
Dy(t) mean differenttiation of function y(t) w.r.t t
Also return y(t) with values of k and theta inserted
답변 (1개)
Bjorn Gustavsson
2021년 10월 5일
0 개 추천
You have 2 unknown parameters k and theta. You have one condition for y at t=0 and one condition for dy/dt at t=0. Since you have an explicit expression for y(t) you can differentiate that to give you an explicit expression for dy/dt. That will result in 2 expressions for y and dy/dt. This should make it possible to determine the 2 parameters. Simply start by manually differentiating y(t) unsing the product rule.
HTH
댓글 수: 7
Amey Raj
2021년 10월 5일
Bjorn Gustavsson
2021년 10월 5일
OK, to me this seems like a very odd task for a matlab-beginner - we would typically start by numerical computations of all kinds, leading to integrals and integration of differential equations etc - and then perhaps a bit of symbolic computations.
If you're a matlab-beginner start with looking through the on-ramp material: on-ramp_1, on-ramp_2. That will bring you up to speed on what you feel you need faster than what you'll get here.
As for forcing someone to solve this problem with matlab you could try something like:
sym y t theta k % Define the variables as symbolic
y = k*exp(-t/2)*cos(theta + (3^(1/2)*t)/2);
Then have a look at the help for diff (the symbolic version) which will show you how to differentiate y. After that you will have one expression for y and one expression for Dy. Those you can turn into 2 equations for the conditions at t=0, then it is very straightforward to solve those two equations and the equation t==0 using solve (see help and documentation for solve for examples). Now I've given you sufficient information to work this out, if I give you more I'll do the entire task for you which would hamper your matlab-development...
HTH
Amey Raj
2021년 10월 5일
Bjorn Gustavsson
2021년 10월 5일
First (I guess), your definition of y is independent of t - unless x depends on t somehow.
If you want to have a differential equation of the type dy/dt + 6*y = RHS you might have to live with something more explicit:
my_ode = diff(y,t) + 6*y == RHS;
HTH
Bjorn Gustavsson
2021년 10월 5일
Then the question becomes more of "how to parse user input and interpret that" - once that is solved it should be comparatively easy to build a sum of derivatives of a polynomial or a differential equation. I suggest you open a new question on that.
카테고리
도움말 센터 및 File Exchange에서 Programming에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!