how to solve attached problem using fsolve and ode45??

i want to solve this in the following manner :
USING FSOLVE
1) calculate x3, x4 from given x1,x2.
2) calculate x5 from x1,x3 and x6 from x1,x3,x5
3) use ODE 45 to calculate x7 and x8 from x5 and x6
4) update x1 and x2 from x7 and x8
5) run this till we reached to desire value of x1 and x2.

回答 (1 件)

darova
darova 2020 年 1 月 30 日

0 投票

You need only x7 and x8 initial
function main
[t,x] = ode45(@func,tspan,[x7 x8]);
plot(t,x)
function dx = func(~,x)
x1 = x(2)^2 + 3*x(1);
x2 = x(1) - x(2);
% x3 .. x6
dx(1,1) = -x5;
dx(2,1) = -x6;
end
end

9 件のコメント

chirag patel
chirag patel 2020 年 1 月 30 日
Will it give all x variable answer ??
darova
darova 2020 年 1 月 30 日
no
darova
darova 2020 年 1 月 30 日
But you can do this
[t,x] = ode45(@func,tspan,[x7 x8]);
x7 = x(:,1);
x8 = x(:,2);
x1 = x8.^2 - 3*x7;
plot(t,x1)
chirag patel
chirag patel 2020 年 1 月 30 日
編集済み: chirag patel 2020 年 1 月 30 日
i think i have not stated problem clearly.
i want to solve this in the following manner :
USING FSOLVE
1) calculate x3, x4 from given x1,x2.
2) calculate x5 from x1,x3 and x6 from x1,x3,x5
3) use ODE 45 to calculate x7 and x8 from x5 and x6
4) update x1 and x2 from x7 and x8
5) run this till we reached to desire value of x1 and x2.
darova
darova 2020 年 1 月 30 日
I don't understand why do you need fsolve. Did you try the code from answer?
chirag patel
chirag patel 2020 年 1 月 30 日
If I want all variable to solve then how to implement in matlab??
darova
darova 2020 年 1 月 30 日
DId you read my comments above? DO you understand me?
chirag patel
chirag patel 2020 年 1 月 30 日
No
darova
darova 2020 年 1 月 30 日
please?

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

カテゴリ

質問済み:

2020 年 1 月 30 日

コメント済み:

2020 年 1 月 30 日

Community Treasure Hunt

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

Start Hunting!

Translated by