MATLAB怎么把一个式子算出的好多数赋值给一个矩阵

2024-11-16 05:38:52
推荐回答(1个)
回答1:

你的z应该是一个3*3矩阵,应该写作z=zeros(3,3)

程序修改如下:
x=[1 4 5 ]'
z=zeros(3,3);%%%%%%%%%%%%%%%%%%
for i=1:1:3
for j=1:1:3
y=2*i*x(i)+j*x(i)
z(i,j)=y;%%%%%%%%%%%%%%%%%%%%%
end
end

如果满意就采纳吧吧