generating a matrix question
显示 更早的评论
i want to generate a matrix that each element is the sum of its row and column ive tried usin the henkel command but it didnt work is there an alternative or more simple solution thx
采纳的回答
更多回答(1 个)
Andrei Bobrov
2013-12-11
编辑:Andrei Bobrov
2013-12-11
s = [3 4];% let s - size new matrices
A = hankel(2:s(1)+1,s(1)+1:sum(s));
or
A = bsxfun(@plus,(1:s(1))',1:s(2));
or
s = [3 4];
[ii,jj] = ndgrid(1:s(1),1:s(2));
A = ii + jj;
类别
在 帮助中心 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!