Saving a rxcx matrix into a larger rxcy matrix

1 次查看(过去 30 天)
I currently have a system where a collect gives me 16538 by 15 columns of data as an output for every collect in the series. I am looking to save these 15 columns of data after every scan into a larger matrix so that the raw data can be accessed at a later date for analysis.
for individual 16538 by 1 data sets the following "Data(:, counter) = Spectrum;" works fine, where Data collects 16538 by counter columns until the capture ends.
Instead I am trying to find a way to save Data where the spectrum is 16538 by 15 instead. Anyone have any ideas to sort this simply?

回答(1 个)

Tejas
Tejas 2024-12-26
编辑:Tejas 2024-12-26
Hello Ryan,
The spectrum with a size of (16538, 15) can be incorporated into a larger matrix 'Data' by simply replacing the columns in 'Data' with the 'Spectrum' data.
Here are the steps to add 'Spectrum' data from each scan to the 'Data' matrix:
  • Start by pre-allocating the 'Data' matrix according to the total number of scans.
Data = zeros(16538, 15 * totalScans);
  • For each scan, identify the columns in the 'Data' matrix that need to be replaced with data from the 'Spectrum'.
for counter = 1:totalScans
Spectrum = rand(16538, 15); % Replace with your Specturm data
startCol = (counter - 1) * 15 + 1;
endCol = counter * 15;
Data(:, startCol:endCol) = Spectrum;
end
For a better understanding of this solution, run the following command in the MATLAB command line to access the documentation on array indexing:
>> web(fullfile(docroot, "matlab/learn_matlab/array-indexing.html"));

类别

Help CenterFile Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息

产品


版本

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by