loop in dsolve code needed
1 次查看(过去 30 天)
显示 更早的评论
D = 10; R = 0.5; a = 0.1; b = 0.5; A = 1.5; B = 1; C = 1; P = 7; xb = 5; N = 5;
syms x f0(x) g0(x) f(k) g(k)
eqn0 = [ diff(f0,3) == 0, diff(g0,2) == 0 ];
cond0 = [ f0(0) == 0, subs(diff(diff(f0)),0) == -2/C, subs(diff(f0),xb) == 0, g0(0) == 1, g0(xb) == 0 ];
F0 = dsolve(eqn0,cond0); f0 = F0.f0; g0 = F0.g0;
for k = 1:N
eqn1 = [ a*diff(f(k),3) + b*(f(k-1)*diff(f(k-1),2) - diff(f(k-1))^2 ) - D*diff(f(k-1)) == 0,...
diff(g(k),2) + P*B*( f(k-1)*diff(g(k-1)) - 2*diff(f(k-1))*g(k-1) ) + 3*R*A*g(k-1)^2*diff(g(k-1)) == 0];
cond1 = [ subs(f(k),0) == 0, subs(diff(diff(f(k))),0) == 0, subs(diff(f(k)),xb) == 0, subs(g(k),0) == 0, subs(g(k),xb) == 0 ];
F1 = dsolve(eqn1,cond1); fk = F1.f(k); gk = F1.g(k);
end
f = sum(fk,k,1,N); g = sum(gk,k,1,N);
%% Any contribution in loop formation will be appreciated
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Calculus 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!