filling an empty matrix using a for loop

조회 수: 14 (최근 30일)
Bas Bloemendaal
Bas Bloemendaal 2020년 5월 20일
답변: Srivardhan Gadila 2020년 5월 27일
for j = abs(1:20:size(Bz,1))
Yi = Bz(j,minK(1,1));
lateral = find_coordinate(R2,Z2,Bz,Yi,0);
M_tot_spions_z = langevinfunc2(n,Kb,T,Brex(j,minK(1,1)), f, Vc, Ms,N);
U_det_r = abs((Yi.*M_tot_spions_z)/100e-9); % Counts 100[nV] Induced voltage [V]
figure;
plot(T_comb,U_det_r)
title([' Detected signal @ lateral distance =', num2str(abs(lateral)),' [m]'])
xlabel('Time [s]')
ylabel('Voltage [V]')
hold on
plot(T_comb, Noise)
end
Hello,
Is there a possibity to save all values for U_det_r so I can use these later on in a different plot?

채택된 답변

Srivardhan Gadila
Srivardhan Gadila 2020년 5월 27일
You can define U_det_r as a cell array or normal array and store the values corresponding to each iteration as follows:
U_det_r = {};
for j = abs(1:20:size(Bz,1))
Yi = Bz(j,minK(1,1));
lateral = find_coordinate(R2,Z2,Bz,Yi,0);
M_tot_spions_z = langevinfunc2(n,Kb,T,Brex(j,minK(1,1)), f, Vc, Ms,N);
U_det_r{j} = abs((Yi.*M_tot_spions_z)/100e-9); % Counts 100[nV] Induced voltage [V]
figure;
plot(T_comb,U_det_r{j})
title([' Detected signal @ lateral distance =', num2str(abs(lateral)),' [m]'])
xlabel('Time [s]')
ylabel('Voltage [V]')
hold on
plot(T_comb, Noise)
end
Refer to cell array & Matrices and Arrays documentation for more information.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Signal Radiation and Collection에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by