用matlab给三维数组中特定行列赋值

上传:dispense_29070 浏览: 25 推荐: 0 文件:zip 大小:17.27KB 上传时间:2023-07-21 22:47:09 版权申诉

matlab使用sub2ind函数将特定行列赋值给三维数组

matlab用sub2ind函数将特定行列中的元素值赋为1,示例如下:

a=zeros(5);

i = [2;3;4];

j = [1;4;2];

a(sub2ind(size(a), i, j))=1

a = 0 0 0 1 0

0 0 1 0 0

0 0 0 0 0

0 0 0 0 0

0 0 0 0 0

用户上传资源,matlab三维数组,某几行或某几列,赋值,sub2ind函数

上传资源
用户评论