Effacer les filtres
Effacer les filtres

What changes should have been made to run the code

2 vues (au cours des 30 derniers jours)
MINATI
MINATI le 18 Mai 2019
Commenté : MINATI le 19 Mai 2019
%% HERE is the code
format long
wt=pi/2;
t=1;
% t=0.01:0.01:5;
% w=pi/2;
w=wt./t;
R=10;H=2;M=5;Kp=0.5;Gr=5;Gc=5;Kc=1;Pr=7;Sc=0.3;
y=0:0.01:5;
% y=0;
P1=abs(R-H); P2=M+(1/Kp);P3=sym(P2+1i*w);P4=sym(P2-1i*w);
P6=Gr/(P1-P2);P7=Gc/(Kc-P2);P5=(P6+P7);P8=(P1*Pr-P2)/(Pr-1);P9=Gr/(Pr-1);
P10=(Sc*Kc-P2)/(Sc-1);P11=Gc/(Sc-1);P12=-(P11/P10^2)-(P9/P8^2);P13=(P11/P10)+(P9/P8);
T1=(t+(y/2)*(sqrt(Pr/P1))).*exp(y*sqrt(Pr*P1)).*(1-erf((y/2).*sqrt(Pr./t)+sqrt(P1.*t)));
T2=(t-(y/2)*(sqrt(Pr/P1))).*exp(-y*sqrt(Pr*P1)).*(1-erf((y/2)*sqrt(Pr./t)-sqrt(P1.*t)));
C1=(t+(y/2)*(sqrt(Sc/Kc))).*exp(y*sqrt(Sc/Kc)).*(1-erf((y/2)*sqrt(Sc./t)+sqrt(Kc.*t)));
C2=(t-(y/2)*(sqrt(Sc/Kc))).*exp(-y*sqrt(Sc/Kc)).*(1-erf((y/2)*sqrt(Sc./t)-sqrt(Kc.*t)));
T=(T1+T2)/2;C=(C1+C2)/2;
U1=exp(y*sqrt(P2)).*(1-erf(y./(2.*sqrt(t))+ sqrt(P2.*t)));
U2=exp(-y*sqrt(P2)).*(1-erf(y./(2.*sqrt(t))- sqrt(P2.*t)));
U3=exp(y*sqrt(P1*Pr)).*(1-erf((y./2)*sqrt(Pr./t)+ sqrt(P1.*t)));
U4=exp(-y*sqrt(P1*Pr)).*(1-erf((y./2)*sqrt(Pr./t)- sqrt(P1.*t)));
U5=exp(y*sqrt(Sc*Kc)).*(1-erf((y./2)*sqrt(Sc./t)+ sqrt(Kc.*t)));
U6=exp(-y*sqrt(Sc*Kc)).*(1-erf((y./2)*sqrt(Sc./t)- sqrt(Kc.*t)));
U7=exp(y*sqrt(P3)).*(1-erf(y./(2.*sqrt(t))+ sqrt(P3.*t)));
U8=exp(-y*sqrt(P3)).*(1-erf(y./(2.*sqrt(t))- sqrt(P3.*t)));
U9=exp(y*sqrt(P4)).*(1-erf(y./(2.*sqrt(t))+ sqrt(P4.*t)));
U10=exp(-y*sqrt(P4)).*(1-erf(y./(2.*sqrt(t))- sqrt(P4.*t)));
U=(P12/2).*(U1+U2)+(P13/2)*((t+(y/(2*sqrt(P2)))).*U1+(t-(y/(2*sqrt(P2)))).*U2)+((P9/(2*(P8^2))).*exp(-P8.*t)+(P11/(2*(P10^2))).*exp(-P10.*t)).*(U1+U2)+...
(P9/(2*P8^2)).*(U3+U4)-(P9/(2*P8))*((t+(y/2)*sqrt(Pr/P1)).*U3+(t-(y/2)*sqrt(Pr/P1)).*U4)-(P9/(2*P8^2)).*exp(-P8.*t).*(U3+U4)+...
(P11/(2*P10^2)).*(U5+U6)-(P11/(2*P10))*((t+(y/2)*sqrt(Sc/Kc)).*U5+(t-(y/2)*sqrt(Sc/Kc)).*U6)-...
(P11/(2*P10^2)).*exp(-P10.*t).*(U5+U6) +exp(1i*wt)*(1/4).*(U7+U8)+exp(-1i*wt)*(1/4).*(U9+U10);
%% S1: Partial derivative of 'U(t,y)' w.r.t 'y', S2: Partial derivative of 'T(t,y)' w.r.t 'y',
S1= - diff(U,y);
S2= - diff(T,y);
v_t=0.01:0.01:5;
Sk = subs(S1,y,0);
Nu=subs(S2,y,0);
figure(1)
plot(v_t,vpa(subs(Sk,t,v_t)))
xlabel(' t');
ylabel('Sk');
hold on
figure(2)
plot(v_t,vpa(subs(Nu,t,v_t)))
xlabel(' t');
ylabel('Nu');
hold on
%%We need to draw graph of Partial derivative of 'U(t,y)' w.r.t 'y' and 'T(t,y)' w.r.t 'y'
at y=0 for t=0.01:0.01:5;
%% While running the code the following ERROR occurs:
Error using sym/diff (line 69)
The second argument must be a variable or a nonnegative integer specifying the number of differentiations.
Error in (line 37)
S1= - diff(U,y);
%%ANOTHER error for S2 is :
Error using diff
Difference order N must be a positive integer scalar.
Error in (line 38)
S2= - diff(T,y);
  5 commentaires
KALYAN ACHARJYA
KALYAN ACHARJYA le 18 Mai 2019
S1= - diff(U,y);
%............^.....
Here the y value must be in integer as per diff definitions
Y = diff(X,n) calculates the nth difference by applying the diff(X) operator recursively n times.
In your case y is 1x501 double, therefore it reflect an error as below
Error using sym/diff (line 70)
Second argument must be a variable or a nonnegative integer specifying the number of differentiations.
Error in ans_may19 (line 37)
S1= - diff(U,y);
MINATI
MINATI le 19 Mai 2019
So what changes should we do

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Mathematics dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by