From: Javi Montes Montes on
Hello,
I need help. I can't run a program to solve a sistem of differential equations. I am trying to simulate a hydraulic system countenig a valve and a cylinder using the ode45. This is my .m file:
function dxdt= sistemas(t,x)

dxdt=[x(3);x(4);(((Ap/10)*(P-Ap^2*x(3)^2*Den/(pi()^2*D^2*x(2)^2*Cd^2*202600000))-K3*(Xpre+x(1)))*1000/m2);...
((K1*Ypre1-K2*Ypre2-(P-(Ap^2*x(3)^2*Den*(pi()^2*D^2*x(2)^2*Cd^2*202600000)))*(Apil/10+2*pi()*D*0.103*x(2)*Cd^2*Ang)...
-x(2)*(2*pi()*D*0.1013*P*cd^2*Ang +K2+K1))*1000/m1)];
And the error is
??? Error using ==> mpower
Matrix must be square.

Error in ==> sistemas at 21
dxdt=[x(3);x(4);(((Ap/10)*(P-Ap^...

could anybody help me? I don't know how to solve it
Thank you in advanced
Javi Montes
From: Md Sahidullah on
Dear Javi,

It is very difficult to say exactly where the problem occurs without running the code.
As far as I know to calculate X^Y Y must be a square matrix. Check whether it is violated in your code.

Thanking You.

Sahidullah

"Javi Montes Montes" <jmontes(a)sapaplacencia.com> wrote in message <hm5k08$l6f$1(a)fred.mathworks.com>...
> Hello,
> I need help. I can't run a program to solve a sistem of differential equations. I am trying to simulate a hydraulic system countenig a valve and a cylinder using the ode45. This is my .m file:
> function dxdt= sistemas(t,x)
>
> dxdt=[x(3);x(4);(((Ap/10)*(P-Ap^2*x(3)^2*Den/(pi()^2*D^2*x(2)^2*Cd^2*202600000))-K3*(Xpre+x(1)))*1000/m2);...
> ((K1*Ypre1-K2*Ypre2-(P-(Ap^2*x(3)^2*Den*(pi()^2*D^2*x(2)^2*Cd^2*202600000)))*(Apil/10+2*pi()*D*0.103*x(2)*Cd^2*Ang)...
> -x(2)*(2*pi()*D*0.1013*P*cd^2*Ang +K2+K1))*1000/m1)];
> And the error is
> ??? Error using ==> mpower
> Matrix must be square.
>
> Error in ==> sistemas at 21
> dxdt=[x(3);x(4);(((Ap/10)*(P-Ap^...
>
> could anybody help me? I don't know how to solve it
> Thank you in advanced
> Javi Montes
From: Oleg Komarov on
"Javi Montes Montes" <jmontes(a)sapaplacencia.com> wrote in message <hm5k08$l6f$1(a)fred.mathworks.com>...
> Hello,
> I need help. I can't run a program to solve a sistem of differential equations. I am trying to simulate a hydraulic system countenig a valve and a cylinder using the ode45. This is my .m file:
> function dxdt= sistemas(t,x)
>
> dxdt=[x(3);x(4);(((Ap/10)*(P-Ap^2*x(3)^2*Den/(pi()^2*D^2*x(2)^2*Cd^2*202600000))-K3*(Xpre+x(1)))*1000/m2);...
> ((K1*Ypre1-K2*Ypre2-(P-(Ap^2*x(3)^2*Den*(pi()^2*D^2*x(2)^2*Cd^2*202600000)))*(Apil/10+2*pi()*D*0.103*x(2)*Cd^2*Ang)...
> -x(2)*(2*pi()*D*0.1013*P*cd^2*Ang +K2+K1))*1000/m1)];
> And the error is
> ??? Error using ==> mpower
> Matrix must be square.
>
> Error in ==> sistemas at 21
> dxdt=[x(3);x(4);(((Ap/10)*(P-Ap^...
>
> could anybody help me? I don't know how to solve it
> Thank you in advanced
> Javi Montes

X^2 should be a square matrix if you're elevating the entire matrix.
ELSE if you want each element of X to be ^2 (3,4 or n) then use the .^ operator.

Oleg