saving 3D matrix from one loop

조회 수: 1 (최근 30일)
Sharif Khalil
Sharif Khalil 2018년 7월 17일
댓글: Sharif Khalil 2018년 7월 17일
I have AF_Field_P that is 181X361 matrix, and I want Pp to be 1001X181X361, which means, I want to save all the values with different Xp. The output from this is only the last 181X361 matrix, which is for Xp = 1e3;
if true
% code
end
Xp = 20:1*Km;
Yp = 1*Km;
rho_p = sqrt(Xp.^2+Yp^2+HT^2);
FSPL_p = (4*pi*rho_p/lmda).^2; % Free Space Path Loss
for pp = 1:length(Xp)
Pp(pp) = (4*pi*abs(AF_Field_P).^2)/FSPL_p(pp);
end

채택된 답변

Jesus Sanchez
Jesus Sanchez 2018년 7월 17일
Try
Pp = zeros(length(Xp),length(size(AF_Field_P,1)),length(size(AF_Field_P,2)));
for pp = 1:length(Xp)
Pp(pp,:,:) = ...
end
With 3D matrix you need to address directly the dimension where you are saving the data, and then the other two. Note that the inizialization of Pp is not required, but matlab says that it is faster this way :)
  댓글 수: 1
Sharif Khalil
Sharif Khalil 2018년 7월 17일
Thank you, it works fine

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Biomedical Imaging에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by