Create a matrix for data with various iterations
Show older comments
hey to all, thanks for reading this in advance. I want to calculate Surveillance_SignalFD and Reference_SignalFD as a matrix, where each rows corresponds to a different y_transmitter. The code I have, for each y_transmitter it calculates this variables, but on the next iteration it replaces the values of the previous one. I want to save all the values of each iteration in a matrix.
Thanks guys
for i=1:numel(waypoints)
Y_transmitter = waypoints(i);
for xx=1:200
for yy=1:200
if AoI(xx,yy) ~= 0 % Target detection
X_target= xx;
Y_target= yy;
Surveillance_SignalFD=(1/(R1+R2))*X_QPSK.*exp(-1*j*k0*(R1+R2)); % Surveillance Signal frequency domain
Reference_SignalFD=(1/Rd)*X_QPSK.*exp(-1*j*k0*Rd); % Reference Signal frequency domain
Answers (1)
Rangesh
on 26 Sep 2023
Hello Miguel,
I understand that you want to save the values of every iteration in a matrix. To achieve it, you can follow the steps below:
- Create a zero matrix with the preallocated size - numel(waypoints)x200x200 as follows:
Surveillance_SignalFD=zeros(numel(waypoints),200,200)
Reference_SignalFD=zeros(numel(waypoints),200,200)
2.Store the values by assigning the elements of the matrix as follows:
Surveillance_SignalFD(i,xx,yy)=(1/(R1+R2))*X_QPSK.*exp(-1*j*k0*(R1+R2)); % Surveillance Signal frequency domain
Reference_SignalFD(I,xx,yy)=(1/Rd)*X_QPSK.*exp(-1*j*k0*Rd); % Reference Signal frequency domain
You can refer to the following MATLAB Documentations of “numel”, “matrices and arrays” and “zeros” for more information:
- numel: https://www.mathworks.com/help/releases/R2021b/fixedpoint/ref/numel.html
- zeros: https://www.mathworks.com/help/releases/R2021b/matlab/ref/zeros.html
- matrices and arrays: https://www.mathworks.com/help/releases/R2021b/matlab/matrices-and-arrays.html
I hope this resolves your query.
Thanks,
Rangesh.
Categories
Find more on Multirate Signal Processing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!