How to extract data from a specified row number (omitting first row)

6 visualizzazioni (ultimi 30 giorni)
Hi all,
I have a cell array from which I want to extract data from the rows between parts highlighted yellow in the image below (just part of the array shown).
I want to first indicate the start and end of these rows, as following:
%% find the kewords for start and end
idx_rtoe_start = find(strcmp(data_raw(:, 2), '"Right Toe"'));
idx_rtoe_end = find(strcmp(data_raw(:, 2), '"HX210.11.31.M7-LF S0021"'));
%% indices between idx_rtoe_start and idx_rtoe_end
idx = arrayfun(@(idxStart, idxEnd) idxStart:idxEnd, idx_rtoe_start, idx_rtoe_end,...
'UniformOutput', false);
However, '"HX210.11.31.M7-LF S0021"' occurs for the first time earlier in the file (before 'righ toe') and the code above (bolded part) gives the the first location it occurs. I want this to start from the second time it occurs. I cannot use another keyword as these also occur earlier in the file.
Please help

Risposta accettata

Simon Chan
Simon Chan il 16 Ago 2021
Just get rid of the first data in the index:
idx_rtoe_end = find(strcmp(data_raw(:, 2), '"HX210.11.31.M7-LF S0021"'));
idx_rtoe_end = idx_rtoe_end(2:end);

Più risposte (1)

Tomaszzz
Tomaszzz il 16 Ago 2021
Modificato: Tomaszzz il 16 Ago 2021
This does not work beacuse I did not explain well.
Please see part of data attached and the code.
The problem is that this idx_rtoe_end = find(strcmp(data_raw(:, 2), '"HX210.11.31.M7-LF S0021"')) gives me the first location of ''idx_rtoe_end'' 'as 6 (first time '"HX21...'' occurs) whereas I want it to be from 221 and onwards(second time '"HX21...'' occurs and so on; like in the image above) so that I get the variables of interests from the right place (between parts highlighted yellow in the image).
While the idea from Simon could work, the remaining part of the code gives problems.
Thanks
  2 Commenti
Simon Chan
Simon Chan il 16 Ago 2021
Just have a quick look on your data and the length of your extracted data should be the same.
Why don't you just set the end index to be start index + (a number)
idx_rtoe_start = find(strcmp(data_raw(:, 2), '"Right Toe"'));
idx_rtoe_end = idx_rtoe_start + 17; % Just an example

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by