如何用Matlab编写程序解一个复杂方程组,但是过程要用maple解方程?? 用matlab解复杂方程组
\u6c42\u9ad8\u624b\u89e3\u7b54\u7528Matlab \u89e3\u590d\u6742\u65b9\u7a0b\u7ec4\u7684\u89e3syms x y z a b c
[x,y,z]=solve('72.8*(1+cos(a))=2*(sqrt(x*21.8)+sqrt(25.5*y)+sqrt(25.5*z))','50.8*(1+cos(b))=2*sqrt(x*50.8)','48*(1+cos(c))=2*(sqrt(x*29)+sqrt(47*y)+sqrt(1.92*z))','x,y,z')
x =
12.700000000000000000000000000000+25.400000000000000000000000000000*cos(b)+12.700000000000000000000000000000*cos(b)^2
y =
-.98416931170728906540241988580218*cos(c)+9.7643439805890752790240685157559*cos(a)*cos(b)-23.462398366292790782350185322144*cos(c)*cos(b)+7.1488996766620738069752563394849*cos(b)^2+3.3341639162497969191291895638814*cos(a)^2+.40958164398297044880227538559881*cos(a)+.59974496762043211062439587258181*cos(b)-16.023090169105698668480172257920*cos(c)*cos(a)+19.250659611845600192713968847131*cos(c)^2+.12578649948056747012125686189223e-1
z =
.15194565438596826916006412565125e-193*(.58477278352492431981436322974990e98+.58477278352492431981436322974990e98*cos(a)-.26731041191058757560106827855831e98*((cos(b)+1.)^2)^(1/2)-1.*(-.64771139107889760381210034820223e194*cos(c)+.64262081202967154457022801098613e195*cos(a)*cos(b)-.15441309237244940736312726425476e196*cos(c)*cos(b)+.47049056490306928474554525841306e195*cos(b)^2+.21943134403702282352778341593461e195*cos(a)^2+.82783874266682206962299704487537e192+.26955798481907364090410143645319e194*cos(a)+.39471018111316040430045885264655e194*cos(b)-.10545277016218098275353846992100e196*cos(c)*cos(a)+.12669437431192070703927236534687e196*cos(c)^2)^(1/2))^2
______________________________
\u5c31\u662f\u4ee3\u5165\u6c42\u503c\u5c31\u884c\u4e86\uff0c\u4f8b\u5982\uff1a\uff08\u63a5\u7740\u4e0a\u9762\u7684\u6c42X\uff09
x=subs(x,{a,b,c},{77.7,33.3,48.5})
x =
127/10+127/5*cos(333/10)+127/10*cos(333/10)^2
__________________________________
\u5176\u5b9e\u5728\u4e00\u5f00\u59cb\u5c31\u7ed9\u5b9aa,b,c\u7684\u503c\u4e5f\u662f\u53ef\u4ee5\u7684\uff0c\u5982\u679c\u4e0d\u8981\u6c42\u4e00\u5b9a\u8981\u6c42\u89e3\u6790\u89e3\u7684\u8bdd\uff0c\u697c\u4e0b\u8bf4\u7684fsolve\u5012\u4e5f\u662f\u4e00\u79cd\u9009\u62e9
function hhh
To=400
Tf=0.75*To+0.25*302
V=0.6*4.6*0.3/sqrt(1+1)*sqrt(2*9.8*2.5*(Tf-302)/302)
Nu=4.9+0.0606*(V/4.6/0.04*0.04/0.000016*0.701*2*0.04/2.5)^1.2/(1+0.0909*(V/4.6/0.04*0.04/0.000016*0.701*2*0.04/2.5)^0.7*0.701^0.17)
h=0.0267*Nu/2.5
q=1.128*V*1005*(Tf-302)/0.75/4.6/2.2
eq1=sym('(Tg-302)/(1/23.26+0.01/1.1)+h*(Tg-Tf)+hwg*(Tg-Tw)=0.7*600');
eq2=sym('h*(Tg-Tf)+h*(Tw-Tf)=q');
eq5=sym('h*(Tw-Tf)+1/(1/8.72+0.2/0.49)*(Tw-299)+hwg*(Tw-Tg)=0');
%eq7=sym('5.67*10^8*(Tg^2+Tw^2)*(Tw+Tg)/(1/0.8+1/0.94-1)=hwg');
[Tg,Tw,hwg]=solve(eq1,eq2,eq5,'Tg,Tw,hwg');
Tg=subs(Tg),Tw=subs(Tw),hwg=subs(hwg)
hwg1=5.67*10^8*(Tg^2+Tw^2)*(Tw+Tg)/(1/0.8+1/0.94-1)
x0=[Tg h Tf hwg Tw q To Nu V]
%x0=[11.2698 0.9291 455.5052 -1.8440 -11.2698 113.7074 487.3698 97.0550 0.0031]
fsolve(@myfuns,x0)
function eqs=myfuns(x)
Tg=x(1);h=x(2);Tf=x(3);hwg=x(4);Tw=x(5);q=x(6);To=x(7);Nu=x(8);V=x(9);
eq1=(Tg-302)/(1/23.26+0.01/1.1)+h*(Tg-Tf)+hwg*(Tg-Tw)-0.7*600;
eq2=h*(Tg-Tf)+h*(Tw-Tf)-q;
eq3=1.128*V*1005*(Tf-302)/0.75/4.6/2.2-q;
eq4=0.75*To+0.25*302-Tf;
eq5=h*(Tw-Tf)+1/(1/8.72+0.2/0.49)*(Tw-299)+hwg*(Tw-Tg);
eq6=0.6*4.6*0.3/sqrt(1+1)*sqrt(2*9.8*2.5*(Tf-302)/302)-V;
eq7=5.67*10^8*(Tg^2+Tw^2)*(Tw+Tg)/(1/0.8+1/0.94-1)-hwg;
eq8=0.0267*Nu/2.5-h;
eq9=4.9+0.0606*(V/4.6/0.04*0.04/0.000016*0.701*2*0.04/2.5)^1.2/(1+0.0909*(V/4.6/0.04*0.04/0.000016*0.701*2*0.04/2.5)^0.7*0.701^0.17)-Nu;
eqs=[eq1;eq2;eq3;eq4;eq5;eq6;eq7;eq8;eq9];
\u7ed3\u679c\uff1a
Optimizer appears to be converging to a point which is not a root.
Norm of relative change in X is less than max(options.TolX^2,eps) but
sum-of-squares of function values is greater than or equal to sqrt(options.TolFun)
Try again with a new starting guess.
ans =
1.0e+004 *
-3.6696 0.0000 0.0376 -0.0002 3.6696 2.2196 0.0400 0.0020 0.0002
1 Maple15以上版本,可以将Maple语言转换成其他语言,包括MATLAB,当然不能转换Maple中的专有函数运算。具体的命令如下:
CodeGeneration['Matlab']('XXXXXXXXXXXXXXX');
XXXXXXXXXXXx部分就是Maple程序内容。例如如下图,上面是Maple程序,下面是自动生成的MATLAB代码:
2 有免费的Maple Player下载,可以用于阅读、运算Maple程序、文件,但是不能修改。
3 Maplesoft有个叫MapleNet的技术,可以直接通过网页加载Maple文件,并运行、计算。
举个例子:http://202.121.241.38:80/maplenet/worksheet/uploads/0203ThreeEq.mw
这个链接就是一个MapleNet的例子,将一个Maple在网页上实现了,并可以做计算。
可以尝试直接在三个数学框里输入方程,然后拖动下滑动条进行求解。
绛旓細syms x f f=(672.68^2+x^2+900.22*x)^(1/2)-(672.68^2+x^2-999.80*x)^(1/2)-9*(10^5)/(x+450);solve(f)
绛旓細绗笁锛屾垜浠繘鍏ユ垜浠垱寤虹殑matlab鐨鍏ㄦ柊鐣岄潰鍚庯紝鎴戜滑灏卞彲浠缂栧啓绋嬪簭浜嗭紝鍦ㄨ繖閲屾垜鍏堝啓涓灏忔绋嬪簭浣滀负绀鸿寖銆傜鍥涳紝鍦ㄦ垜浠啓瀹屼竴娈电▼搴忎箣鍚庯紝鎴戜滑鍏堣鎶婂畠杩涜淇濆瓨锛屽叾鎿嶄綔杩囩▼鏄湪璇ョ晫闈㈡渶涓婃柟鎵惧埌file锛堢偣鍑伙級锛岀劧鍚庢壘鍒皊ave all锛堢偣鍑伙級銆備箣鍚庡氨鍚庡脊鍑轰竴涓晫闈㈠湪鍏朵腑閫夋嫨浣犺瀛樻。鐨勪綅缃紙鐐瑰嚮淇濆瓨鍗冲彲锛夈...
绛旓細鍙互鍙傝冧笅闈㈢殑浠g爜锛缂栧啓M鏂囦欢锛屼唬鐮佸涓嬨侳=input('Enter the temperature in degrees Fahrenheit?');C=5/9*(F-32);disp([num2str(F),' deg F equals ',num2str(C,'%.1f'),' deg C'])鐒跺悗杩愯鍗冲彲
绛旓細n=28;syms p;a=n/2:n;b=n/2:-1:0;sum=0;for i=1:length(a)sum=sum+nchoosek(n,a(i))*p^(a(i))*(1-p)^(b(i));end p=double(solve(sum-0.9,p));disp(p(p==real(p)));瀹冧竴涓湁28涓鏁板煙鐨勮В锛屽瓨鍦ㄧ粨鏋減涓紝鎴戞渶鍚庢樉绀轰簡浜嗕袱涓疄鏁板煙鐨勮В锛屽涓嬶細-0.2332 0....
绛旓細杩愯浜嗕綘鐨绋嬪簭锛屽瓨鍦ㄧ潃涓嬪垪鍑犱釜闂锛1銆佺敤涓嬪垪杩欎釜浠g爜姹傝В锛屽叾t銆亂鍊兼槸鏃犳硶浠e叆鏂圭▼鐨勩倄=solve('465*sin(x)+200=120*cos(t*1.2+pi/3)+369*sin(x-y)','x');鎵浠ヨ蒋浠朵細鎻愮ず鏈夊叧sym鐨勪俊鎭2銆佸瑕佹樉绀簒鍊硷紝鍏惰璇彞鏈鍚庝笉鑳芥湁鍒嗗彿锛堬紱锛夈傜敱浜庝綘缁欏嚭鐨則銆亂鍊兼槸浠ヤ竴缁勫悜閲忓舰寮...
绛旓細1.x=0:pi/20:2*pi;axis([0 2*pi -1 1])plot(x,sin(x),'r')hold on plot(x,cos(x),'b')legend('sin(x)','cos(x)')axis([0 2*pi -1 1])2.price=input('璇疯緭鍏ュ晢鍝佷环鏍硷細');if(price<200)realprice=price elseif(price<500)realprice=price*(1-0.03)elseif(price<...
绛旓細%娑堝厓鍚庣殑绯绘暟鐭╅樀 function x=SolveUpTriangle(A,b)N=size(A);n=N(1);for i=n:-1:1 if(i<n)s=A(i,(i+1):n)*x((i+1):n,1);else s=0;end x(i,1)=(b(i)-s)/A(i,i);end 绋嬪簭濡備笂锛岃嚜宸辩畻鍚с傝繖涓笢瑗垮簲璇ュ皾璇曡嚜宸缂栫▼ 鍙傝冭祫鏂欙細matlab甯哥敤绠楁硶 ...
绛旓細绗簩绉嶆柟娉曪細鍒╃敤Matlab涓殑solver鍑芥暟(鍖呮嫭ode45銆乷de23銆乷de15s绛)鏉ユ眰瑙e井鍒嗘柟绋嬬殑鏁板艰В锛岃繖绉嶆柟娉曟槸鏈甯哥敤鐨勬柟娉曪紝瀵逛簬dsolve鍑芥暟闅句互姹傝В鐨勬柟绋嬪氨鍙互鍒╃敤杩欑鏂规硶姹傝В鏂圭▼鐨勬暟鍊艰В銆1銆 鎵撳紑Matlab-->鏂板缓涓涓剼鏈枃浠剁敤浜缂栧啓姹傝В绋嬪簭銆2銆 鍦ㄨ剼鏈枃浠朵腑杈撳叆姹傝В绋嬪簭-->鐐瑰嚮淇濆瓨-->鐐瑰嚮杩愯銆3銆...
绛旓細鐢╮oots(p)鍑芥暟姹傝В 鍏朵腑p鏄柟绋嬬殑鍚勬鏂圭殑绯绘暟缁勬垚鐨勭煩闃 姣斿 浣犺繖閬撻鐨勬眰鏍绋嬪簭涓: roots(p)matlab杩愯鍚庣殑缁撴灉涓:ans =10.3180 4.0487 1.8166 + 1.3141i 1.8166 - 1.3141i 濡備綍鐢∕ATLAB姹傝ВLOGISTIC鏂圭▼ 鑷充簬Lyapunov鏂圭▼鐨勬眰瑙,浣犲彲浠ユ煡涓,涓嬮潰鎴缂栧啓鐨勪竴涓笘瀛,閲岄潰璇︾粏璇存槑浜哃yapunov鏂圭▼璇濡備綍浣跨敤Matlab姹...
绛旓細杩欐槸鎴鍐鐨绋嬪簭锛屾墍鏈夐棶棰橀兘鏈夊洖绛旓紝浣嗕笉涓瀹氬畬鍠勶紝 鑻ユ湁闂璇锋寚鍑恒傗斺斺攈=10; %鍒濆楂樺害h锛岃涓10绫筹紝鍙嚜琛岃缃 d=0.2; %鍚告敹姣斾緥d锛岃涓0.2锛屽彲鑷 g=9.8; %閲嶅姏鍔犻熷害g int=40; %姣忔寮硅捣璺▼鐨勯噰鏍锋鏁帮紝鍙嚜璁俱侶(1)=h; %绗竴娆℃挒鍑诲湴闈㈢粡鍘嗙殑璺濈 T(1)=(2...