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

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
所以想请问一下怎么改写成矩阵运算?提升速度

 Respuesta aceptada

0 votos

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(:)];

Más respuestas (0)

Categorías

Más información sobre MATLAB 快速入门 en Centro de ayuda y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!