lnly 发表于 2007-7-3 21:35

求广义逆时出错

A=
A =
   1   1
   2   2
>> B=vpa(A)

B =

[ 1., 1.]
[ 2., 2.]

>> pinv(B)
??? Error using ==> svd
Too many input arguments.
Error in ==> D:\MATLAB6p5\toolbox\matlab\matfun\pinv.m
On line 20==>    = svd(A,0);


请教各位大侠,这个问题怎么解决.我是个初学者,在编程时遇到了类似的问题.
我现在必须用vpa求出数组的精确解.但应用vpa后,就不能用pinv求该数组的广义逆了.就出现了上面的问题,不知应怎么解决.

[ 本帖最后由 eight 于 2007-7-5 15:03 编辑 ]

咕噜噜 发表于 2007-7-4 10:31

回复 #1 lnly 的帖子

把整个程序贴上来看看

lnly 发表于 2007-7-4 15:05

clc
clear
syms theta
u0=(4*pi)*(10^-7);N=180;i0=2;R=25;thick=25;e=0.04;r=24.55;wide=10;alf=pi/4;L=219;
Kc=u0*N^2*i0^2*R*thick/8;
Ce=e/(R-r);
sumx=0.0;
for jj=1:4
    if(jj==1)
      n=0;
    elseif(jj==2)
      n=3;
    elseif(jj==3)
      n=4;
    else
      n=7;
      end
theta1=pi*(1+2*n)/8-asin(wide/(2*R));theta2=pi*(1+2*n)/2+asin(wide/(2*R));
A=Kc/(R-r)^2;
B=sin(theta)/^2;
F=simple(int(B,theta,theta1,theta2))%,latex(F)
vpa(F,60);
Fx1y=A*F
vpa(Fx1y,60);
sumx=sumx+vpa(Fx1y,60);
end
sumx
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
sumy=0.0;
for jj=1:4
    if(jj==1)
      n=1;
    elseif(jj==2)
      n=2;
    elseif(jj==3)
      n=5;
    else
      n=6;
      end
theta1=pi*(1+2*n)/8-asin(wide/(2*R));theta2=pi*(1+2*n)/2+asin(wide/(2*R));
A=Kc/(R-r)^2;
B=cos(theta)/^2;
F=simple(int(B,theta,theta1,theta2));%,latex(F)
vpa(F,60);
Fy1x=A*F ;
vpa(Fy1x,60);
sumy=sumy+vpa(Fy1x,60);
end
sumy
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
下面还有一半

lnly 发表于 2007-7-4 15:14

接着上面的程序
e1x=e*cos(alf)
e1y=e*sin(alf)
e2x=(2*L/thick)*e*cos(alf)
e2y=(2*L/thick)*e*sin(alf)

Ky1x=sumy/e1x
Ky2x=sumy/e2x
Kx1y=sumx/e1y
Kx2y=sumx/e2y
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
w=1000;m=1.5;l=219;a=109;b=110;D=49.1;k1=2.5;k2=0.01;k3=249.33;k4=203.24;k5=1.25e+3;k6=1.01e+3;
j1=pi*D^4/32;
j2=pi*D^4/64;
M=;
C=;
K=[(k5+k3*k1+Ky1x),(k6+k4*k1+Ky2x),0,0;0,0,(k5+k3*k1+Kx1y),(k6+k4*k1+Kx2y);-a*(k3*k1+k5+Ky1x),b*(k6+k4*k1+Ky2x),0,0;0,0,-a*(k3*k1+k5+Kx1y),b*(k6+k4*k1+Kx2y)];
I=eye(4);
mm=zeros(4);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%转换为标准特征值问题

G=;
cri=eig(G)
pp=imag((cri));
wn=(abs(imag(cri)));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
   A1=[-wn(1,1)^2*M(1,2)+...
      i*wn(1,1)*C(1,2)+K(1,2),...
   -wn(1,1)^2*M(1,3)+i*wn(1,1)...
       *C(1,3)+K(1,3),-wn(1,1)^2*...
   M(1,4)+i*wn(1,1)*C(1,4)+K(1,4);...
    -wn(1,1)^2*M(2,2)+i*wn(1,1)*C(2,2)+K(2,2), -wn(1,1)^2*M(2,3)+i*wn(1,1)*C(2,3)+K(2,3), -wn(1,1)^2*M(2,4)+i*wn(1,1)*C(2,4)+K(2,4);...
   -wn(1,1)^2*M(3,2)+i*wn(1,1)*C(3,2)+K(3,2),-wn(1,1)^2*M(3,3)+i*wn(1,1)*C(3,3)+K(3,3),-wn(1,1)^2*M(3,4)+i*wn(1,1)*C(3,4)+K(3,4);...
-wn(1,1)^2*M(4,2)+i*wn(1,1)*C(4,2)+K(4,2),-wn(1,1)^2*M(4,3)+i*wn(1,1)*C(4,3)+K(4,3),-wn(1,1)^2*M(4,4)+i*wn(1,1)*C(4,4)+K(4,4)]
B1=-[-wn(1,1)^2*M(1,1)+i*wn(1,1)*C(1,1)+K(1,1); -wn(1,1)^2*M(2,1)+i*wn(1,1)*C(2,1)+K(2,1);-wn(1,1)^2*M(3,1)+i*wn(1,1)*C(3,1)+K(3,1); -wn(1,1)^2*M(4,1)+i*wn(1,1)*C(4,1)+K(4,1)]

X(:,1)=pinv(A1)*(B1)
input('The program is over!')
运行后总有这样的错误:
??? Error using ==> svd
Too many input arguments.

Error in ==> D:\MATLAB6p5\toolbox\matlab\matfun\pinv.m
On line 20==>    = svd(A,0);

Error in ==> D:\MATLAB6p5\work\MATLAB\练习\zhenxing4.m
On line 86==> X(:,1)=pinv(A1)*(B1)

yizi0000 发表于 2007-7-5 01:49

原帖由 lnly 于 2007-7-3 21:35 发表 http://www.chinavib.com/forum/images/common/back.gif
A=
A =
   1   1
   2   2
>> B=vpa(A)

B =

[ 1., 1.]
[ 2., 2.]

>> pinv(B)
??? Error using ==> svd
Too many input arguments.
Error in ==> D:\MATLAB6p5\toolbox\ma ...

A是个矩阵(double类型的),B的类型是sym,不能直接传递给pin()求解,所以报错说输入参数不对.
将原来程序中的
X( : ,1 )=pinv(A1)*(B1)这一句修改成
A_1=double(A1);B_1=double(B1);
X( : ,1 )=pinv(A_1)*(B_1)
就没事了.如果想看X( : ,1 )精确形式,可以再用vpa(X)看一下,跟楼主想要的应该是一样的.不知道说的对不对.

lnly 发表于 2007-7-5 08:40

谢谢了!我明白了!:@)
页: [1]
查看完整版本: 求广义逆时出错