Create a loop to do Afmag for matrixes
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Heu guys, this is probably very easy but i m struggling with it right now, thanks in advance.
I have this code, Initially I calculated reference_signalcut as a vector, but now it is a matrix, is there any way I could apply this to a matrix or do a for loop to apply it for each column of reference_signalcut.
reference_signalcut is a matrix 23979 by 400, with a signal in frequency domain.
Thank you
[afmag,delay] = ambgfun(Reference_SignalCut,fs,1e6,'Cut','Doppler');
afmag = afmag*1; % Select plot gain *1
afmag(afmag>1 )= 1;
0 comentarios
Respuestas (1)
Moksh
el 22 de Sept. de 2023
Editada: Moksh
el 22 de Sept. de 2023
Hi Miguel,
I understand that you can perform the required processing steps when “Reference_SignalCut” is a 1D vector. Now that this is a 2D matrix, you wish to perform the same steps on all the columns of this matrix.
You can use a for loop in MATLAB, to traverse on all the columns of the “Reference_SignalCut” matrix and fetch them using simple indexing. After getting the column you can continue using the same processing steps.
Here is an example code for fetching columns of “Reference_SignalCut”:
% Generating example Reference Signal matrix of specified size
Reference_SignalCut = rand(23979, 400);
sz = size(Reference_SignalCut);
% Iterating over the columns of Reference Signal matrix
for i = 1:sz(2)
% ith column of the matrix
signal_col = Reference_SignalCut(:, i);
% Perform the required computations on the column
[afmag,delay] = ambgfun(signal_col,fs,1e6,'Cut','Doppler');
afmag = afmag*1; % Select plot gain *1
afmag(afmag>1 )= 1;
end
I have assumed that you already have the necessary matrix, so the above code shows one way to traverse on the columns of a randomly generated 2D matrix.
For more information about “for loops”, please refer to the following documentation:
Hope this information helps!
Best Regards,
Moksh Aggarwal
0 comentarios
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!