Create a new matrix to apply a function
1 view (last 30 days)
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
Ganesh Gudipati on 15 Jun 2022
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
Refer Matrices and Arrays for more information.