Saving a rxcx matrix into a larger rxcy matrix

1 visualizzazione (ultimi 30 giorni)
Ryan
Ryan il 19 Lug 2022
Modificato: Tejas il 26 Dic 2024
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?

Risposte (1)

Tejas
Tejas il 26 Dic 2024
Modificato: Tejas il 26 Dic 2024
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"));

Categorie

Scopri di più su Resizing and Reshaping Matrices in Help Center e File Exchange

Prodotti


Release

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by