Solve a system of differential equations which has blkdiag
1 view (last 30 days)
Show older comments
I want to solve following equation:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1302260/image.png)
with
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1302265/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1302270/image.png)
Matrices A and C are defined.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1302275/image.png)
I want use ode45 to solve, but I don't know to define matrix B.
function dpdt = control_law(t,xe)
global A C
x = xe(1:2*n,1);
y = xe(2*n+1:end,1);
dxdt = Ax +By (????????)
dydt = C*x;
dpdt = [dxdt;dydt];
end
I tried some of the analysis but to no avail
0 Comments
Answers (3)
Luca Ferro
on 21 Feb 2023
Edited: Luca Ferro
on 21 Feb 2023
given i as identity with coeherent dimensions to x:
blkdiag(x'.*i)
edit: to create i use the eye(n) function, where n is the dimensions
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!