
如何用MATLAB编写六元一次方程组
这是我编的程序,但是不对a=2.578b=40s=82XA=a*(cos(s)+(pi/180)*(s+b)*sin(s))YA=a*(sin(s)-(pi/180)*(...
这是我编的程序,但是不对
a=2.578
b=40
s=82
XA=a*(cos(s)+(pi/180)*(s+b)*sin(s))
YA=a*(sin(s)-(pi/180)*(s+b)*cos(s))
XB=a*(cos(s+180)+(pi/180)*(s+180-b)*sin(s+180))
YB=a*(sin(s+180)-(pi/180)*(s+180-b)*cos(s+180))
[R1,R2,XO1,X02,YO1,YO2]=solve('(XO1-XA)^2+(YO1-YA)^2=R1^2','YO1=(a-X01*cos(s))/sin(s)','(XO2-XB)^2+(YO2-YB)^2=R2^2','YO2=-1*(a+X02*cos(s))/sin(s)','R2=R1+(180-2*b)*(PI/180)*a','R1+R2=sqrt((XO1-XO2)^2+(YO1-YO2)^2)','R1','R2','XO1','XO2','YO1','YO2')
错误提示
Configuration:
MATLAB Version: 6.5.0.180913a (R13)
Operating System: Microsoft Windows XP
Window System: Version 5.1 (Build 2600: Service Pack 3)
Processor ID: x86 Family 15 Model 12 Stepping 2, AuthenticAMD
Virtual Machine: Java 1.3.1_01 with Sun Microsystems Inc. Java HotSpot(TM) Client VM
(mixed mode)
Register State:
EAX = 162e7638 EBX = 00000000
ECX = 00000101 EDX = 1ac403d8
ESI = 1ac403d8 EDI = 1ac403d8
EBP = 00dfa238 ESP = 00dfa1fc
EIP = 1630a001 FLG = 00010246
Stack Trace:
[0] mapleoem.dll:0x1630a001(0x1ac403d8, 4, 0x16309e9f, 0x1ac403d8)
This error was detected while a MEX-file was running. If the MEX-file
is not an official MathWorks function, please examine its source code
for errors. Please consult the External Interfaces Guide for information
on debugging MEX-files.
If it is an official MathWorks function, please
follow these steps in reporting this problem to The MathWorks so
that we have the best chance of correcting it:
1. Send this crash report to segv@mathworks.com for automated analysis.
For your convenience, this information has been recorded in:
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\matlab_crash_dump.2572
2. Also, if the problem is reproducible, send the crash report to
support@mathworks.com along with:
- A specific list of steps that will reproduce the problem
- Any M, MEX, MDL or other files required to reproduce the problem
- Any error messages displayed prior to this crash report
A technical support engineer will contact you with further information.
Thank you for your assistance. Please save your workspace and restart
MATLAB before continuing your work.
Error in ==> D:\ruanjiananzhuang\toolbox\symbolic\maplemex.dll
Error in ==> D:\ruanjiananzhuang\toolbox\symbolic\maple.m
On line 116 ==> [result,status] = maplemex(statement);
Error in ==> D:\ruanjiananzhuang\toolbox\symbolic\solve.m
On line 65 ==> maple('_EnvExplicit := true;');
Error in ==> D:\ruanjiananzhuang\work\Untitled2.m
On line 11 ==> [R1,R2,XO1,X02,YO1,YO2]=solve('(XO1-XA)^2+(YO1-YA)^2=R1^2','YO1=(a-X01*cos(s))/sin(s)','(XO2-XB)^2+(YO2-YB)^2=R2^2','YO2=-1*(a+X02*cos(s))/sin(s)','R2=R1+(180-2*b)*(PI/180)*a','R1+R2=sqrt((XO1-XO2)^2
>> 展开
a=2.578
b=40
s=82
XA=a*(cos(s)+(pi/180)*(s+b)*sin(s))
YA=a*(sin(s)-(pi/180)*(s+b)*cos(s))
XB=a*(cos(s+180)+(pi/180)*(s+180-b)*sin(s+180))
YB=a*(sin(s+180)-(pi/180)*(s+180-b)*cos(s+180))
[R1,R2,XO1,X02,YO1,YO2]=solve('(XO1-XA)^2+(YO1-YA)^2=R1^2','YO1=(a-X01*cos(s))/sin(s)','(XO2-XB)^2+(YO2-YB)^2=R2^2','YO2=-1*(a+X02*cos(s))/sin(s)','R2=R1+(180-2*b)*(PI/180)*a','R1+R2=sqrt((XO1-XO2)^2+(YO1-YO2)^2)','R1','R2','XO1','XO2','YO1','YO2')
错误提示
Configuration:
MATLAB Version: 6.5.0.180913a (R13)
Operating System: Microsoft Windows XP
Window System: Version 5.1 (Build 2600: Service Pack 3)
Processor ID: x86 Family 15 Model 12 Stepping 2, AuthenticAMD
Virtual Machine: Java 1.3.1_01 with Sun Microsystems Inc. Java HotSpot(TM) Client VM
(mixed mode)
Register State:
EAX = 162e7638 EBX = 00000000
ECX = 00000101 EDX = 1ac403d8
ESI = 1ac403d8 EDI = 1ac403d8
EBP = 00dfa238 ESP = 00dfa1fc
EIP = 1630a001 FLG = 00010246
Stack Trace:
[0] mapleoem.dll:0x1630a001(0x1ac403d8, 4, 0x16309e9f, 0x1ac403d8)
This error was detected while a MEX-file was running. If the MEX-file
is not an official MathWorks function, please examine its source code
for errors. Please consult the External Interfaces Guide for information
on debugging MEX-files.
If it is an official MathWorks function, please
follow these steps in reporting this problem to The MathWorks so
that we have the best chance of correcting it:
1. Send this crash report to segv@mathworks.com for automated analysis.
For your convenience, this information has been recorded in:
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\matlab_crash_dump.2572
2. Also, if the problem is reproducible, send the crash report to
support@mathworks.com along with:
- A specific list of steps that will reproduce the problem
- Any M, MEX, MDL or other files required to reproduce the problem
- Any error messages displayed prior to this crash report
A technical support engineer will contact you with further information.
Thank you for your assistance. Please save your workspace and restart
MATLAB before continuing your work.
Error in ==> D:\ruanjiananzhuang\toolbox\symbolic\maplemex.dll
Error in ==> D:\ruanjiananzhuang\toolbox\symbolic\maple.m
On line 116 ==> [result,status] = maplemex(statement);
Error in ==> D:\ruanjiananzhuang\toolbox\symbolic\solve.m
On line 65 ==> maple('_EnvExplicit := true;');
Error in ==> D:\ruanjiananzhuang\work\Untitled2.m
On line 11 ==> [R1,R2,XO1,X02,YO1,YO2]=solve('(XO1-XA)^2+(YO1-YA)^2=R1^2','YO1=(a-X01*cos(s))/sin(s)','(XO2-XB)^2+(YO2-YB)^2=R2^2','YO2=-1*(a+X02*cos(s))/sin(s)','R2=R1+(180-2*b)*(PI/180)*a','R1+R2=sqrt((XO1-XO2)^2
>> 展开
展开全部
在命令窗口输入:
a=2.578;
b=40;
s=82;
XA=a*(cos(s)+(pi/180)*(s+b)*sin(s));
YA=a*(sin(s)-(pi/180)*(s+b)*cos(s));
XB=a*(cos(s+180)+(pi/180)*(s+180-b)*sin(s+180));
YB=a*(sin(s+180)-(pi/180)*(s+180-b)*cos(s+180));
eq1=sym('(XO1-XA)^2+(YO1-YA)^2-R1^2=0');
eq2=sym('(a-X01*cos(s))/sin(s)-YO1=0');
eq3=sym('(XO2-XB)^2+(YO2-YB)^2-R2^2=0');
eq4=sym('-1*(a+X02*cos(s))/sin(s)-YO2=0');
eq5=sym('R1+(180-2*b)*(PI/180)*a-R2=0');
eq6=sym('sqrt((XO1-XO2)^2+(YO1-YO2)^2)-(R1+R2)=0');
[R1,R2,XO1,X02,YO1,YO2]=solve(eq1,eq2,eq3,eq4,eq5,eq6)
内存小的话估计做不出来 我运行了好长时间得到:
R1 =
3.1245232508881301293497148656453
3.0468692638718807027956609673456
2.632143835798611137278653338811
-11.952482580163550828912633712551
1.975115999992427481786355706215*i -5.174715102659608044219609931371
-1.975115999992427481786355706215*i - 5.174715102659608044219609931371
R2 =
7.6239820625295117786589896668089
7.5463280755132623521049357685093
7.1316026474399927865879281399746
-7.4530237685221691796033589113872
1.975115999992427481786355706215*i- 0.67525629101822639491033513020735
-1.975115999992427481786355706215*i-0.67525629101822639491033513020735
XO1 =
5.1463789250182107757121163570486
3.2133211617032770155067665723914
3.3432251025827072786785569969932
7.9115498770959459658638501034415
0.61866317984173350790563580449*i + 2.5468186004144903578215661569772
2.5468186004144903578215661569772 - 0.61866317984173350790563580449*i
X02 =
-2.7042576197829580471917853711494
-4.5817512056255897213414276955407
-4.1504011480699691363140476006738
-2.8448730366121955354673379128386
2.2592399925444148985649893389173*i- 3.7317038826732750448498597519813
-2.259239992544414898564989338917*i- 3.7317038826732750448498597519813
YO1 =
-7.3728897836388566967044557650532
-1.5120559474920105993953789738583
-1.9059114372779854943251020683299
-15.756605876465858387179084260143
0.5087117901368674511594992694813- 1.8757236159237857446622264920114*i
1.87572361592378574466222649201*i+ 0.50871179013686745115949926948131
YO2 =
-0.031372752806629165376348484469766
5.6609961685365918359666275764056
4.3531868208166513358112133769144
0.39495883876641661086590212483449
3.0837394474846890262576944352721- 6.8497850625911309509904543583704*i
6.849785062591130950990454358370*i+ 3.0837394474846890262576944352721
a=2.578;
b=40;
s=82;
XA=a*(cos(s)+(pi/180)*(s+b)*sin(s));
YA=a*(sin(s)-(pi/180)*(s+b)*cos(s));
XB=a*(cos(s+180)+(pi/180)*(s+180-b)*sin(s+180));
YB=a*(sin(s+180)-(pi/180)*(s+180-b)*cos(s+180));
eq1=sym('(XO1-XA)^2+(YO1-YA)^2-R1^2=0');
eq2=sym('(a-X01*cos(s))/sin(s)-YO1=0');
eq3=sym('(XO2-XB)^2+(YO2-YB)^2-R2^2=0');
eq4=sym('-1*(a+X02*cos(s))/sin(s)-YO2=0');
eq5=sym('R1+(180-2*b)*(PI/180)*a-R2=0');
eq6=sym('sqrt((XO1-XO2)^2+(YO1-YO2)^2)-(R1+R2)=0');
[R1,R2,XO1,X02,YO1,YO2]=solve(eq1,eq2,eq3,eq4,eq5,eq6)
内存小的话估计做不出来 我运行了好长时间得到:
R1 =
3.1245232508881301293497148656453
3.0468692638718807027956609673456
2.632143835798611137278653338811
-11.952482580163550828912633712551
1.975115999992427481786355706215*i -5.174715102659608044219609931371
-1.975115999992427481786355706215*i - 5.174715102659608044219609931371
R2 =
7.6239820625295117786589896668089
7.5463280755132623521049357685093
7.1316026474399927865879281399746
-7.4530237685221691796033589113872
1.975115999992427481786355706215*i- 0.67525629101822639491033513020735
-1.975115999992427481786355706215*i-0.67525629101822639491033513020735
XO1 =
5.1463789250182107757121163570486
3.2133211617032770155067665723914
3.3432251025827072786785569969932
7.9115498770959459658638501034415
0.61866317984173350790563580449*i + 2.5468186004144903578215661569772
2.5468186004144903578215661569772 - 0.61866317984173350790563580449*i
X02 =
-2.7042576197829580471917853711494
-4.5817512056255897213414276955407
-4.1504011480699691363140476006738
-2.8448730366121955354673379128386
2.2592399925444148985649893389173*i- 3.7317038826732750448498597519813
-2.259239992544414898564989338917*i- 3.7317038826732750448498597519813
YO1 =
-7.3728897836388566967044557650532
-1.5120559474920105993953789738583
-1.9059114372779854943251020683299
-15.756605876465858387179084260143
0.5087117901368674511594992694813- 1.8757236159237857446622264920114*i
1.87572361592378574466222649201*i+ 0.50871179013686745115949926948131
YO2 =
-0.031372752806629165376348484469766
5.6609961685365918359666275764056
4.3531868208166513358112133769144
0.39495883876641661086590212483449
3.0837394474846890262576944352721- 6.8497850625911309509904543583704*i
6.849785062591130950990454358370*i+ 3.0837394474846890262576944352721
已赞过
已踩过<
评论
收起
你对这个回答的评价是?

2024-08-11 广告
模拟实验模型作为科研与工程领域的重要工具,其核心价值在于精准再现复杂系统或过程,以低成本、低风险的方式预测实际效果。华夏艺匠模型科技通过精细设计与高精度制作,确保模型能够准确反映原型的物理特性、行为模式及潜在变化。我们利用先进材料和技术,使...
点击进入详情页
本回答由BJ华夏艺匠提供
展开全部
我粘贴了你的那段 程序 放在M文件里运行,好半天 给出来 一堆quit:
和几个错误,好像是最后一行有毛病,算不下去了
.
.
.
.
.
Quit:
Quit:
Quit:
Quit:
Quit:
Quit:
Error in ==> maple at 113
[result,status] = maplemex(statement);
Error in ==> solve at 119
[R,stat] = maple('solve',eqns,vars);
Error in ==> fff at 8
[R1,R2,XO1,X02,YO1,YO2]=solve('(XO1-XA)^2+(YO1-YA)^2=R1^2','YO1=(a-X01*cos(s))/sin(s)','(XO2-XB)^2+(YO2-YB)^2=R2^2','YO2=-1*(a+X02*cos(s))/sin(s)','R2=R1+(180-2*b)*(PI/180)*a','R1+R2=sqrt((XO1-XO2)^2
>>
我用3G内存的机器,弄完了,MATLAB2006a 占了1.8G内存
你换个MATLAB版本,代码可能有毛病,上面两位已经给了,好像比你写的多好几行
和几个错误,好像是最后一行有毛病,算不下去了
.
.
.
.
.
Quit:
Quit:
Quit:
Quit:
Quit:
Quit:
Error in ==> maple at 113
[result,status] = maplemex(statement);
Error in ==> solve at 119
[R,stat] = maple('solve',eqns,vars);
Error in ==> fff at 8
[R1,R2,XO1,X02,YO1,YO2]=solve('(XO1-XA)^2+(YO1-YA)^2=R1^2','YO1=(a-X01*cos(s))/sin(s)','(XO2-XB)^2+(YO2-YB)^2=R2^2','YO2=-1*(a+X02*cos(s))/sin(s)','R2=R1+(180-2*b)*(PI/180)*a','R1+R2=sqrt((XO1-XO2)^2
>>
我用3G内存的机器,弄完了,MATLAB2006a 占了1.8G内存
你换个MATLAB版本,代码可能有毛病,上面两位已经给了,好像比你写的多好几行
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
仔细检查你的输入法。
以下是我的M文件:
clear;
a=2.578;
b=40;
s=82;
XA=a*(cos(s)+(pi/180)*(s+b)*sin(s));
YA=a*(sin(s)-(pi/180)*(s+b)*cos(s));
XB=a*(cos(s+180)+(pi/180)*(s+180-b)*sin(s+180));
YB=a*(sin(s+180)-(pi/180)*(s+180-b)*cos(s+180));
syms R1 R2 XO1 XO2 YO1 YO2;
E1=(XO1-XA)^2+(YO1-YA)^2-R1^2;
E2=YO1-(a-XO1*cos(s))/sin(s);
E3=(XO2-XB)^2+(YO2-YB)^2-R2^2;
E4=YO2+1*(a+XO2*cos(s))/sin(s);
E5=-R2+R1+(180-2*b)*(pi/180)*a;
E6=R1+R2-sqrt((XO1-XO2)^2+(YO1-YO2)^2);
[R1,R2,XO1,X02,YO1,YO2]=solve(E1,E2,E3,E4,E5,E6,'R1','R2','XO1','XO2','YO1','YO2')
以下是输出结果:
>> AAA
Warning: possibly spurious solutions [solvelib::checkVectorSolutions]
R1 =
3.1245232508881301293497148656453
3.0468692638718807027956609673456
2.632143835798611137278653338811
-11.952482580163550828912633712551
1.975115999992427481786355706215*i - 5.174715102659608044219609931371
- 1.975115999992427481786355706215*i - 5.174715102659608044219609931371
R2 =
7.6239820625295117786589896668089
7.5463280755132623521049357685093
7.1316026474399927865879281399746
-7.4530237685221691796033589113872
1.975115999992427481786355706215*i - 0.67525629101822639491033513020735
- 1.975115999992427481786355706215*i - 0.67525629101822639491033513020735
XO1 =
5.1463789250182107757121163570486
3.2133211617032770155067665723914
3.3432251025827072786785569969932
7.9115498770959459658638501034415
0.61866317984173350790563580449*i + 2.5468186004144903578215661569772
2.5468186004144903578215661569772 - 0.61866317984173350790563580449*i
X02 =
-2.7042576197829580471917853711494
-4.5817512056255897213414276955407
-4.1504011480699691363140476006738
-2.8448730366121955354673379128386
2.2592399925444148985649893389173*i - 3.7317038826732750448498597519813
- 2.2592399925444148985649893389173*i - 3.7317038826732750448498597519813
YO1 =
-7.3728897836388566967044557650532
-1.5120559474920105993953789738583
-1.9059114372779854943251020683299
-15.756605876465858387179084260143
0.50871179013686745115949926948131 - 1.8757236159237857446622264920114*i
1.8757236159237857446622264920114*i + 0.50871179013686745115949926948131
YO2 =
-0.031372752806629165376348484469766
5.6609961685365918359666275764056
4.3531868208166513358112133769144
0.39495883876641661086590212483449
3.0837394474846890262576944352721 - 6.8497850625911309509904543583704*i
6.8497850625911309509904543583704*i + 3.0837394474846890262576944352721
依旧有warning,但是也有解。
以下是我的M文件:
clear;
a=2.578;
b=40;
s=82;
XA=a*(cos(s)+(pi/180)*(s+b)*sin(s));
YA=a*(sin(s)-(pi/180)*(s+b)*cos(s));
XB=a*(cos(s+180)+(pi/180)*(s+180-b)*sin(s+180));
YB=a*(sin(s+180)-(pi/180)*(s+180-b)*cos(s+180));
syms R1 R2 XO1 XO2 YO1 YO2;
E1=(XO1-XA)^2+(YO1-YA)^2-R1^2;
E2=YO1-(a-XO1*cos(s))/sin(s);
E3=(XO2-XB)^2+(YO2-YB)^2-R2^2;
E4=YO2+1*(a+XO2*cos(s))/sin(s);
E5=-R2+R1+(180-2*b)*(pi/180)*a;
E6=R1+R2-sqrt((XO1-XO2)^2+(YO1-YO2)^2);
[R1,R2,XO1,X02,YO1,YO2]=solve(E1,E2,E3,E4,E5,E6,'R1','R2','XO1','XO2','YO1','YO2')
以下是输出结果:
>> AAA
Warning: possibly spurious solutions [solvelib::checkVectorSolutions]
R1 =
3.1245232508881301293497148656453
3.0468692638718807027956609673456
2.632143835798611137278653338811
-11.952482580163550828912633712551
1.975115999992427481786355706215*i - 5.174715102659608044219609931371
- 1.975115999992427481786355706215*i - 5.174715102659608044219609931371
R2 =
7.6239820625295117786589896668089
7.5463280755132623521049357685093
7.1316026474399927865879281399746
-7.4530237685221691796033589113872
1.975115999992427481786355706215*i - 0.67525629101822639491033513020735
- 1.975115999992427481786355706215*i - 0.67525629101822639491033513020735
XO1 =
5.1463789250182107757121163570486
3.2133211617032770155067665723914
3.3432251025827072786785569969932
7.9115498770959459658638501034415
0.61866317984173350790563580449*i + 2.5468186004144903578215661569772
2.5468186004144903578215661569772 - 0.61866317984173350790563580449*i
X02 =
-2.7042576197829580471917853711494
-4.5817512056255897213414276955407
-4.1504011480699691363140476006738
-2.8448730366121955354673379128386
2.2592399925444148985649893389173*i - 3.7317038826732750448498597519813
- 2.2592399925444148985649893389173*i - 3.7317038826732750448498597519813
YO1 =
-7.3728897836388566967044557650532
-1.5120559474920105993953789738583
-1.9059114372779854943251020683299
-15.756605876465858387179084260143
0.50871179013686745115949926948131 - 1.8757236159237857446622264920114*i
1.8757236159237857446622264920114*i + 0.50871179013686745115949926948131
YO2 =
-0.031372752806629165376348484469766
5.6609961685365918359666275764056
4.3531868208166513358112133769144
0.39495883876641661086590212483449
3.0837394474846890262576944352721 - 6.8497850625911309509904543583704*i
6.8497850625911309509904543583704*i + 3.0837394474846890262576944352721
依旧有warning,但是也有解。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
用采用的solve()函数来求解。
solve()基本使用格式:
[x,y]=solve(‘表达式1’,‘表达式2’,'x','y')
对于你给出的四元一次方程组,应这样来输入,输入时应添加运算符,如乘号,*;除号,/
[a,b,c,d]=solve('0.129=a+42*b+(42^2)*c+(42^3)*d','0.132=a+42.5*b+(42.5^2)*c+(42.5^3)*d','0.133=a+42*b+(43^2)*c+(43^3)*d','0.131=a+42*b+(43.5^2)*c+(43.5^3)*d')
solve()基本使用格式:
[x,y]=solve(‘表达式1’,‘表达式2’,'x','y')
对于你给出的四元一次方程组,应这样来输入,输入时应添加运算符,如乘号,*;除号,/
[a,b,c,d]=solve('0.129=a+42*b+(42^2)*c+(42^3)*d','0.132=a+42.5*b+(42.5^2)*c+(42.5^3)*d','0.133=a+42*b+(43^2)*c+(43^3)*d','0.131=a+42*b+(43.5^2)*c+(43.5^3)*d')
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
既然是符号运算,当然要先定义符号变量啊。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询