跪求大家帮我看看一下的matlab程序哪错了,运行不了呢
c1=2.9233;c2=10.2655;c3=6.0149;x=[];h=[];p=[];q=[];x(1)=1;x(2)=1.1;h(1)=0;h(2)=1.1;p(...
c1=2.9233;c2=10.2655;c3=6.0149;
x=[];h=[];p=[];q=[];
x(1)=1;x(2)=1.1;h(1)=0;h(2)=1.1;
p(1)=1;p(2)=1.1;q(1)=1;q(2)=1.1;
r=1/9790;
d=[1;2;3;4];
for k=2:10
f(k)=x(k)+h(k)+p(k)+q(k);
g(k)=c1*x(k).^2+r*q(k);
u(k)=c2*h(k).^2+r*q(k);
v(k)=c3*p(k).^2+r*q(k);
A=[f(k);g(k),u(k);v(k)];
J=[1,1,1,0;
c1*(g(k).^2-g(k-1).^2)/(x(k)-x(k-1)),0,0,r;
0,c2*(u(k).^2-u(k-1)).^2/(h(k)-h(k-1)),0,r;
0,0,c3*(v(k).^2-v(k-1).^2)/(p(k)-p(k-1)),r]
R=d-J\A;
fprintf('%9.5f %9.5f %10.2e %10.2e %9.5f\n',f(k), g(k),u(k),v(k),x(k))
x(k+1)=R(1,:);
h(k+1)=R(2,:);
p(k+1)=R(3,:);
q(k+1)=R(4,:);
end
运行的时候出现All rows in the bracketed expression must have the same
number of columns. 展开
x=[];h=[];p=[];q=[];
x(1)=1;x(2)=1.1;h(1)=0;h(2)=1.1;
p(1)=1;p(2)=1.1;q(1)=1;q(2)=1.1;
r=1/9790;
d=[1;2;3;4];
for k=2:10
f(k)=x(k)+h(k)+p(k)+q(k);
g(k)=c1*x(k).^2+r*q(k);
u(k)=c2*h(k).^2+r*q(k);
v(k)=c3*p(k).^2+r*q(k);
A=[f(k);g(k),u(k);v(k)];
J=[1,1,1,0;
c1*(g(k).^2-g(k-1).^2)/(x(k)-x(k-1)),0,0,r;
0,c2*(u(k).^2-u(k-1)).^2/(h(k)-h(k-1)),0,r;
0,0,c3*(v(k).^2-v(k-1).^2)/(p(k)-p(k-1)),r]
R=d-J\A;
fprintf('%9.5f %9.5f %10.2e %10.2e %9.5f\n',f(k), g(k),u(k),v(k),x(k))
x(k+1)=R(1,:);
h(k+1)=R(2,:);
p(k+1)=R(3,:);
q(k+1)=R(4,:);
end
运行的时候出现All rows in the bracketed expression must have the same
number of columns. 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询