filling an empty matrix using a for loop

13 Ansichten (letzte 30 Tage)
Bas Bloemendaal
Bas Bloemendaal am 20 Mai 2020
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?

Akzeptierte Antwort

Srivardhan Gadila
Srivardhan Gadila am 27 Mai 2020
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.

Weitere Antworten (0)

Produkte


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by