Matlab中运行后出现???In an assignment A(I) = B, the number of elements in B and I must be the same

编码是求中心差分的 高分急求大哥大姐帮忙看看错在哪儿
%%%%central difference methrodclcclear allclose all%%%%intial values of the systemm=17500;c=35;k=875.5;%%%%the expression of excitationsyms tp=10*sin(pi*t/0.6);%%%%intial caculationt0=0.6; %the end of the excitationtotal=1.0; %totla caculation timedt=0.01; %time stepn=total/dt;n1=t0/dt;u1=0;v1=0;a1=(subs(p,0)-c*v1-k*u1)/m;uu=u1-dt*v1+0.5*dt^2*a1;keq=m/dt^2+c/2/dt;b=m/dt^2-c/2/dt;a=k-2*m/dt^2;%%%%form the vector of the%%%%u(1)=uu;u(2)=u1;v(1)=v1;a(1)=a1;%%%%for every time step%%%%for i=2:1:n+1 if i<n1+1 pt=p; else pt=0; end peq(i)=subs(pt,(i-1)*dt)-b*u(i-1)-a*u(i); u(i+1)=peq(i)/keq;v(i)=(u(i+1)-u(i-1))/(2*dt);a(i)=(u(i+1)-2*u(i)+u(i-1))/dt^2;end%%%%to figure out the caculation resultt1=0:dt:total;plot(t1',u(:,2:n+2));%the value corresponding to u(1) is not real

第1个回答  2014-01-09
看提示是 B和I中的元素个数要一致

另外一条建议:问问题要好好排版 整理好了啊 弄这么乱 别人想帮你看都不好弄
第2个回答  2014-01-14
你的程序好乱啊,还要找半天,看不清,你先改下排版啥。以后建议你去matlab论坛看看,专业一点,百度有点水。
相似回答
大家正在搜