How can ı solve invalid indexing or function

1 view (last 30 days)
Dilara Coskun
Dilara Coskun on 17 Jan 2022
Edited: VBBV on 17 Jan 2022
I have an error. how can I solve?
Invalid indexing or function definition. Indexing must follow
MATLAB indexing. Function arguments must be symbolic variables,
and function body must be sym expression.
clc;
clear all;
syms nw W x Q(x) Y Qo
ode1=diff(Q,x)== -nw*W*Y;
cond1 = Q(0)== 0;
cozum1(x)=dsolve(ode1,cond1);
cozum1=simplify(cozum1(x))
syms d W nu P(x) Q
ode2=diff(P,x) == -Q*((3*nu)/(W*2*d.^3));
cond2(x)= P(0)==0;
cozum2(x)=dsolve(ode2,cond2);
cozum2=simplify(cozum2(x))
syms Yx f Po Pref f5 Q Q1 H R W d Pinf lamdac a b Qref s
f1=P(x)-Po==(-3*nu*Q*x)./(2*W*(d.^3)) ;%cozum2=Px-Po
f2=P(x)-Pinf == nu*H*Y/R; %(denklem1=Px-Pinf it is given)
%(P-Po)==(P-Pinf)===>we accepted
a1=(-3*nu*Q*x)/(2*W*(d.^3))== (nu*H*Y/R);
a2=subs(a1,Q,(cozum1))
lamdac=isolate(a2,x) % =====> x equal to characteristic lenght (lamdac)
a4=isolate(a1,Q); % Q(x)= -H*W*(d^3)*R*Y*2/3*R*nu*x (Q(x) is left alone in the above equation a1)
Q(x)= -H*W*(d^3)*Y*2/3*R*x ;
a5=subs(a4,H*Y./R,(Po-Pinf)); %If we substitute the value of (Po-Pinf) in the above equation
Qref=subs(a5,x,lamdac) %=====> Qref
Yx=(Qo/(-nw*W*x)); % from cozum1
Pref=subs(f2,Y,Yx)
Pref == subs(Pref,x,lamdac) %=====> Pref
syms nu H R d W nw Y(x) Q(x) P(x) Pinf s A B C
P(x)=Pinf+(A*Y(x));
dP=diff(P(x),x);
dP==A*Y(x)
dQ=diff(Q(x),x);
dY=diff(Y(x),x);
eqn1=dY+((B/A)*Q)==0
eqn2=dQ+C*Y==0
solLT1=laplace(eqn1,x,s)
solLT2=laplace(eqn2,x,s)
syms Y_LT Q_LT U V Yave L Y_ave
solLT1=subs(solLT1,[laplace(Y(x),x,s) laplace(Q(x),x,s)],[Y_LT Q_LT]);
solLT2=subs(solLT2,[laplace(Y(x),x,s) laplace(Q(x),x,s)],[Y_LT Q_LT]);
solLT1=subs(solLT1,[Y_LT Q_LT],[U V])
solLT2=subs(solLT2,[Y_LT Q_LT],[U V])
%Cramer Rule
Y(0)==(U*s)+(B/A)*V;
Q(0)==U*C+(s*V) ;
A1=[s (B/A);
C s ];
A2=[Y(0), (B/A) ;
Q(0),s];
A3=[s (B/A);
C s;];
detA2=det(A2);
detA3=det(A3);
U=(detA2/detA3)
B1=[s,Y(0);
C,Q(0);];
detB1=det(B1)
V=(detB1/detA3)
Y=ilaplace(U,s,x)
eqnY=subs(Y,[A B C], [(nu.*H./R) (3.*nu./(2*d.^3.*W)) (nw.*W)])
eqnY1=subs(eqnY, ((2.*d.^3.*H)./(3.*nw.*R)).^0.5,lamdac)
Q=ilaplace(V,s,x)
eqnQ=subs(Q, [A B C], [(nu.*H./R) (3.*nu./(2*d.^3.*W)) (nw.*W)])
eqnQ1=subs(eqnQ, ((2.*d.^3.*H)./(3.*nw.*R)).^0.5,lamdac)
%f2=P(x)-Pinf== nu*H*Y(x)/R ====> Y=eqnY1
P(x)=Pinf+ (nu*H.*Y(x)./R)
P(x)==subs(P(x),Y(x),eqnY1)

Answers (1)

VBBV
VBBV on 17 Jan 2022
Edited: VBBV on 17 Jan 2022
clc;
clear all;
syms nw W x Q(x) Y Qo
ode1=diff(Q,x)== -nw*W*Y;
cond1 = Q(0)== 0;
cozum1(x)=dsolve(ode1,cond1);
cozum1=simplify(cozum1(x))
syms d W nu P(x) Q
ode2=diff(P,x) == -Q*((3*nu)/(W*2*d.^3));
cond2(x)= P(0)==0;
cozum2(x)=dsolve(ode2,cond2);
cozum2=simplify(cozum2(x))
syms Yx f Po Pref f5 Q Q1 H R W d Pinf lamdac a b Qref s
f1=P(x)-Po==(-3*nu*Q*x)./(2*W*(d.^3)) ;%cozum2=Px-Po
f2=P(x)-Pinf == nu*H*Y/R; %(denklem1=Px-Pinf it is given)
%(P-Po)==(P-Pinf)===>we accepted
a1=(-3*nu*Q*x)/(2*W*(d.^3))== (nu*H*Y/R);
a2=subs(a1,Q,(cozum1))
lamdac=isolate(a2,x) % =====> x equal to characteristic lenght (lamdac)
a4=isolate(a1,Q); % Q(x)= -H*W*(d^
Q(x)= -H*W*(d^3)*Y*2/3*R*x ;
a5=subs(a4,H*Y./R,(Po-Pinf)); %If we
Qref=subs(a5,x,lamdac) %=====> Qref
Yx=(Qo/(-nw*W*x)); % from cozum1
Pref=subs(f2,Y,Yx)
Pref == subs(Pref,x,lamdac) %=====> Pref
syms nu H R d W nw Y(x) Q(x) P(x) Pinf s A B C
P(x)=Pinf+(A*Y(x));
dP=diff(P(x),x);
dP==A*Y(x)
dQ=diff(Q(x),x);
dY=diff(Y(x),x);
eqn1=dY+((B/A)*Q)==0
eqn2=dQ+C*Y==0
solLT1=laplace(eqn1,x,s)
solLT2=laplace(eqn2,x,s)
syms Y_LT Q_LT U V Yave L Y_ave
solLT1=subs(solLT1,[laplace(Y(x),x,s) laplace(Q(x),x,s)],[Y_LT Q_LT]);
solLT2=subs(solLT2,[laplace(Y(x),x,s) laplace(Q(x),x,s)],[Y_LT Q_LT]);
solLT1=subs(solLT1,[Y_LT Q_LT],[U V])
solLT2=subs(solLT2,[Y_LT Q_LT],[U V])
%Cramer Rule
Y(0)==(U*s)+(B/A)*V;
Q(0)==U*C+(s*V) ;
A1=[s (B/A);
C s ];
A2=[Y(0), (B/A) ;
Q(0),s];
A3=[s (B/A);
C s;];
detA2=det(A2);
detA3=det(A3);
U=(detA2/detA3)
B1=[s,Y(0);
C,Q(0);];
detB1=det(B1)
V=(detB1/detA3)
Y(x)=ilaplace(U,s,x); % change this line
eqnY=subs(Y(x),[A B C], [(nu.*H./R) (3.*nu./(2*d.^3.*W)) (nw.*W)])
eqnY1=subs(eqnY, ((2.*d.^3.*H)./(3.*nw.*R)).^0.5,lamdac)
Q=ilaplace(V,s,x)
eqnQ=subs(Q, [A B C], [(nu.*H./R) (3.*nu./(2*d.^3.*W)) (nw.*W)])
eqnQ1=subs(eqnQ, ((2.*d.^3.*H)./(3.*nw.*R)).^0.5,lamdac)
%f2=P(x)-Pinf== nu*H*Y(x)/R ====> Y=eqnY1
P(x)=Pinf+ (nu*H.*Y(x)./R)
P(x)==subs(P(x),Y(x),eqnY1)
Check with this

Tags

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!