Parse 1 large column of uneven data into an array of columns by nth rows.

2 visualizzazioni (ultimi 30 giorni)
Everyone, this may be a very easy question, and as i mentioned in previous work i am a biochemist trying to apply some basic (I think basic) metlab to help expidite data managemnet. I have a text file that is 4 colunms by 136000 rows (ish). (see attached text). I am running a loop where voltage is constnat and current is measured. The time between each measuremnt is identical OTHER then when the loop occurs creating some larger time gap. I want to extract each loop in reshape (neat metlab word i recently leanr haha) the text so that each colunm is one loop for however many loops there are.
So.. the data file is to large and it wont let me attach. I can explain the data in more detail if needed.
  7 Commenti
David Probst
David Probst il 14 Nov 2022
The "normal" time step for each point should be ~ 0.01-0.07 seconds, and the loop occurs when the delta in time is about 340 seconds (plus and minus some decimal). so in excel I take the differnee in each time point in a seperate colunm, then do conditional formating to highlight points higher then 1 (which only is the loop wait times). After I manually copy and paste each colunm bteween the highlighted region. Obviously this is a VERY long and VERY VERY ineffiecnt. I apoliges if there is missing inofmration you need, I am a biochemcist trying to learn this basic (I think basic) matlab to help out our research.

Accedi per commentare.

Risposte (1)

Bjorn Gustavsson
Bjorn Gustavsson il 11 Nov 2022
If your file contains an equal number of samples for every "loop" and the files contains data from full "loops". Then something like this should work:
n_per_loop = 37; % adjust
idx_time_var = 1; % index to the column with the time-stamps
sz_data = size(datasmaple);
n_loops = floor(sz_data(1)/n_per_loop); % this should get us the number of full loops
% This should extract the time-stamps and put them in an
% [ n_per_loop x n_loops ] array
t_all = reshape(datasmaple(1:(n_per_loop*n_loops),idx_time_var),n_per_loop,n_loops);
for i2 = setdiff(1:sz_data(2),idx_time_var) % Here we loop over the other columns
% Extract those columns reshape them and put them into a cell-array
data_cell_format{i2} = eshape(datasmaple(1:(n_per_loop*n_loops),i2),n_per_loop,n_loops);
end
HTH
  13 Commenti
David Probst
David Probst il 22 Nov 2022
That is a good idea! thank you! I appreicate the support, i am very very novice to coding.

Accedi per commentare.

Categorie

Scopri di più su MATLAB in Help Center e File Exchange

Prodotti


Release

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by