求 下面的运算怎么改成矩阵运算。

ind=1;
for i=1:numel(xm1)
for j=1:numel(ym1)
amp_t(ind,:)=[xm1(i) ym1(j) ampaxyl1(j,i)];
ind=ind+1;
end
end
想实现的功能就是给一个空矩阵赋值 ,但是由于规模很大,非常耗时 numel(xm1)=numel(ym1)=1024
所以想请问一下怎么改写成矩阵运算?提升速度

 Réponse acceptée

0 votes

n=1024;xm1=rand(n,1);ym1=rand(n,1);ampaxyl1=rand(n);
ind=fullfact([n n]);
amp_t=[xm1(ind(:,2)) ym1(ind(:,1)) ampaxyl1(:)];

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB 快速入门 dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!