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 Center および File ExchangeSignal 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