Get data from xls file.
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
Adam Danz
il 12 Lug 2022
Modificato: Adam Danz
il 13 Lug 2022
> 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 Commenti
Vedere anche
Categorie
Scopri di più su Tables in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!