Create a new matrix to apply a function

Hey guys thanks in advance for reading this and helping me.
I have a matrix range_compression(2032 x 400). For each column of that matrix I want to apply a function(freq2time).This function transforms a vector in frequency domain to a vector in time domain. So I need to apply this function in this matrix, so first, I need to save each column of range_compression matrix and apply the function for all the columns.
And I want that after the apllication of the function for each column of range_compression, it saves the variable range_compressed, column by column in another matrix.
How can I do this, thank you
Range_compression=surv_matrix.*conj(ref_matrix);
[time_rc,Range_compressed]=freq2time(Range_compression,doppler_freqSurv);

댓글 수: 5

dpb
dpb 2022년 6월 10일
"The MATLAB way" would be for freq2time to be vectorized internally to operate by column. It would then be consistent with the largest majority of functions (FFT, for example, in the signal processing arena would be a model).
Are you sure it isn't already able to do that?
I never tried to apply it in a column, always in a row. But assuming that this function is able to execute column by column, how could I do the code?
"For each column of that matrix I want to apply a function(freq2time)"
If freq2time is vectorized, then simply
[time_rc,Range_compressed]=freq2time(Range_compression,doppler_freqSurv);
will work and give two arrays of same size as input array.
If it isn't vectorized, it'll tell you and you simply loop over the columns of the input array and save the resulting columns in the output arrays (having then preallocated them, of course).
thats my doubt, how to to that you said for last
dpb
dpb 2022년 6월 10일
Well, did you even try the vector approach first?
Have you even tried to address an array column using the <colon, :> operator as illustrated in the Array Indexing section of the <help/matlab/getting-started-with-matlab> guide in the local/online documentation?
If you are as yet so unfamiliar with basic MATLAB syntax, I'd suggest the time invested in the OnRamp tutorials @<Tutorials/matlab-onramp> will more than pay back.

댓글을 달려면 로그인하십시오.

답변 (1개)

Ganesh Gudipati
Ganesh Gudipati 2022년 6월 15일

0 개 추천

Hi Miguel,
As per my understanding you have a matrix and a function. The function actually process on each column of the matrix and the resultant column will be stored in a different matrix.
The general MATLAB operations used to deal with matrices are attached below
Range_compression(i,j); % to access a cell where row=i and column=j
Range_compression(i,:); % to access all cells where row=i;
Range_compression(:,j); % to access all cells where column=j;
size(Range_compression,1); % gives no of rows in Range_compression
size(Range_compression,2); % gives no of columns in Range_compression
Now you can use a for loop to iterate through all the columns and call freq2time inside the for loop
for j = 1:size(Range_compression,2)
temp = freq2time(Range_compression(:,j))
Range_compressed = [Range_compressed,temp] % appending the column
end
Refer Matrices and Arrays for more information.

카테고리

도움말 센터File Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

제품

릴리스

R2021b

질문:

2022년 6월 10일

답변:

2022년 6월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by