此处为何得到复数??着急
这是从总程序中切下来的一部分程序:function canshu
global p n M0 H0 l
n=5
p=
B=
M0=-10000
H0=10000
l=12
S1=Sumofp1(p,n)
M=Jiedianwanju(n)
fprintf(' 节点号 p(i) S1 M(i)\n')
for i=1:n+1
fprintf('%6d %10.4e %10.4e %10.4e\n',...
i,p(i),S1(i),M(i))
end
return
%计算S1(6,1)各元素的值%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
functionS1=Sumofp1(p,n)
global p n
S1=zeros(n+1,1)
for i=1:n+1
for j=2:i-1
if i<=2
S1(i)=0
else
S1(i)=S1(i)+6*(i-j)*p(j)
end
end
end
end
return
%%%%%%%%%%%%%%%%%%计算M(6,1)各元素的值%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function M=Jiedianwanju(n)
global M0 H0 p l B n S1
M=zeros(n+1,1)
for i=1:n+1
if i<=2
M(i)=-M0-H0*(i-1)*l/n+l.^2*B(i)/(6*n.^2)*((3*i-4)*p(1)+p(i))
else
M(i)=-M0-H0*(i-1)*l/n+l.^2*B(i)/(6*n.^2)*((3i-4)*p(1)+S1(i)+p(i)) %在此处得到复数????????
end
end
end
return
文中标示的部分计算竟然是复数的结果!!十分不解,请高手帮忙 发现问题了,标注行有个3i中间少了个*号!!!
回复 楼主 abench363219 的帖子
LZ贴的程序, 自己有试跑过吗? 还有错误!?还有建议不要自己跟帖
页:
[1]