How to extract data from a specified row number (omitting first row)
2 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
Simon Chan
2021-8-16
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);
0 个评论
更多回答(1 个)
Tomaszzz
2021-8-16
编辑:Tomaszzz
2021-8-16
2 个评论
Simon Chan
2021-8-16
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
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!