Find and extract specific rows and column into new table

조회 수: 6 (최근 30일)
Alyssa Tijerina
Alyssa Tijerina 2018년 6월 17일
답변: Walter Roberson 2018년 6월 17일
This is what I have and it finds the correct rows but it is not creating a new table with the extracted values. It produces a 1x1 table. I am not sure what I am missing.
load Leaf1.txt;
% % Set data source
Wave = Leaf1(:,2);
Ref = Leaf1(:,3);
% % Locate data
R = find(Wave >= 625 & Wave <= 691)
NIR = find(Wave >= 829 & Wave <= 900);
% Create new matrix
New = Leaf1([276:342 2427:2493 4578:4644 6729:6795 8880:8946 11031:11097 13182:13248 15333:15399 17484:17550 19635:19701 480:551 2631:2702 4782:4853 6933:7004 9084:9155 11235:11306 13386:13457 15537:15608 17688:17759 19839:19910]);
% % Save new table
Ref_Leaf1=table(New);
writetable(Ref_Leaf1);

채택된 답변

Walter Roberson
Walter Roberson 2018년 6월 17일
New = Leaf1([276:342 2427:2493 4578:4644 6729:6795 8880:8946 11031:11097 13182:13248 15333:15399 17484:17550 19635:19701 480:551 2631:2702 4782:4853 6933:7004 9084:9155 11235:11306 13386:13457 15537:15608 17688:17759 19839:19910], :);
Ref_Leaf1 = array2table(New, 'VariableNames', {'Wave', 'Ref'});
But I suspect you are more after
Leaf_R = array2table( Leaf1(R, :), 'VariableNames', {'Wave', 'Ref'});
Leaf_NIR = array2table( Leaf1(NIR, :), 'VariableNames', {'Wave', 'Ref'});
writetable(Leaf_R);
writetable(Leaf_NIR);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Statistics and Machine Learning Toolbox에 대해 자세히 알아보기

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by