zfbq2006 发表于 2009-5-18 22:23

有谁能看一下错在哪

v=-30:30;
v=v*pi/180;
y1=atan(69/52*tan(v));
x1=0.23:1;
x2=0.23:1;
x3=0.23:1;
x4=0.23:1;
x5=0.23:1;
x6=0.23:1;
x7=-45*pi/180:15*pi/180;
x8=-15*pi/180:45*pi/180;
mid1=sqrt(1.2^2+x5.^2-2*1.2*x5.*cos(45*pi/180+x7));
mid2=acos((mid1.^2+x1.^2-x3.^2)./(2*x1.*mid1))...
    -acos((1.2-x5.*cos(45*pi/180+x7))./mid1)...
    -45*pi/180;
mid3=sqrt(1^2+x6.^2-2*1*x5.*cos(40*pi/180+x8));
mid4=acos((mid3.^2+x2.^2-x4.^2)./(2*x2.*mid3))...
    -acos((1-x5.*cos(40*pi/180+x8))./mid3)...
    -45*pi/180;
mid5=sqrt(1^2+x6.^2-2*1*x6.*cos(40*pi/180-v-x8));
mid6=acos((mid5.^2+x2.^2-x4.^2)./(2*x2.*mid5))...
    -acos((1-x6.*cos(40*pi/180-v-x8))./mid5)...
    -mid4-40*pi/180;
mid7=sqrt(1.2^2+x1.^2-2*1.2*x1.*cos(45*pi/180-mid6-mid2));
y2=acos((mid7.^2+x5.^2-x3.^2)./(2*x5.*mid7))...
    -acos((1.2-x1.*cos(45*pi/180-mid6-mid2))./mid7)...
   -x7-45*pi/180;

plot(v,y1,'k-',v,y2,'b:');
xlabel('v');
ylabel('y');
title('y-v');
legend('y1','y2');
grid on
本MATLAB程序需要画出y1(v)和y2(v)的图(二维);但是老是说发现minus
Matrix dimensions must agree.或time Matrix dimensions must agree
大家看看吧谢谢,给我指出具体错误!

xiezhh 发表于 2009-5-18 22:36

真受不了啦!v和x8不等长,mid6和mid2不等长,没耐心往下看了。

建议用linspace函数生成等长的向量!!!

cheno9468 发表于 2009-5-19 01:17

mid5=sqrt(1^2+x6.^2-2*1*x6.*cos(40*pi/180-v-x8));
这行有错

LZ其实可以一行一行的执行,这样就能看出哪里出错了
页: [1]
查看完整版本: 有谁能看一下错在哪