Get data from xls file.
조회 수: 2 (최근 30일)
이전 댓글 표시
Hi Everyone, Im a newbie to Matlab. I have a table of 105216x10 in my workspace which i need to get some data from. its only numbers in the table.
In A column i have numbers from 1-15 wheere some are repeated. I only am interested in the rows when in clumn A changes from 6 to7. so basically if number =6 and the number fater is 7 then print that row
have following code but only returns 1.
number6=1;number7=1;
for i=1:length(data)
if data(i,1) == 7 && i-1 == 6
newT(number6) = AA(i-1,:) ;number6 = number6+1 ;
end
if data(i,1) == 8 && i-1 == 7
DDD(number7) = AA(i-1,:) ;number7 = number7+1 ;
end
end
Thanks
Ex
댓글 수: 0
답변 (1개)
Adam Danz
2022년 7월 12일
편집: Adam Danz
2022년 7월 13일
> i need a comand to check the numbers in column A and anywhere that 6 change to 7 show me the entire rows for last 6 and where 7 changes back to 6 show me the last row in 7.
Here's a demo
Create demo table
Produce table T with variable names A,B.
A = [4;5;6;6;7;7;8;6;6;6;5;7;7;6;6;7;7;6;6;7;7];
B = round(rand(size(A))*10,2);
T = table(A,B);
disp(T)
Find index of the last 6 that changes to 7 and the last 7 that changes to 6
dA = [diff(T.A);0];
isLastSix = T.A==6 & dA==1; % bad variable name, change it
isLastSeven = T.A==7 & dA==-1; % bad variable name, change it
Show rows of table for each index
T(isLastSix,:)
T(isLastSeven,:)
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!