重新组装矩阵 [英] reassembled the matrix

查看:115
本文介绍了重新组装矩阵的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是matlab的新用户.我的问题是 通过使用此命令,我制作了一个矩阵

I am new user of matlab. My question is that I make a matrix, by using this command

for i =1:n
    perm(:,i)=emp(:,i); % (where emp is already calculated)
end

然后我要制作一个矩阵

A(i,i)=B(perm(:,i),perm(:,i));

对于i = 1,它使用第一列评估矩阵B,对于i = 2,它使用第二列,依此类推. (烫发是我的问题所在)

that is for i=1 it evaluate the matrix B using first column for i=2 it uses 2nd row and so on. (the perms are the nodes of my problem)

推荐答案

您的第一个循环只是将emp复制到perm.只需将emp复制到perm即可,即

Your first loop just copies emp to perm. It is faster to just copy emp to perm i.e.

perm=emp;

您关于A(i,i)的问题有点令人困惑. A(i,i)是矩阵A的对角线.B(perm(:,i),perm(:,i))返回矩阵,因此A(i,i)= B(perm(:,i) ,perm(:,i))产生错误.您应该多说明一些您想做的事情.

Your question regarding A(i,i) is a little confusing. A(i,i) are the diagonals of the matrix A. B(perm(:,i),perm(:,i)) returns a matrix, thus A(i,i)=B(perm(:,i),perm(:,i)) produces and error. You should clarify a little bit more what you want to do.

这篇关于重新组装矩阵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆