Row index exceeds table dimensions.
22 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
trans=readtable('csv71106.csv');
trans.Properties.VariableNames={'Date','Name','Amount'};
clearvars -except trans,clc;
for k=1:height(trans);
if table2array(trans(k,3))>0;
trans(k,:)=[];
else
continue
end
end
I'm trying to get rid of the positive values in the table ''trans'' with a for loop. Thank you.
0 Kommentare
Akzeptierte Antwort
Tommy
am 2 Apr. 2020
This line:
trans(k,:)=[];
shortens your table trans, but k will keep increasing until it reaches the original height of trans, meaning k will eventually surpass the current height of trans and cause the error.
I believe simply
trans=readtable('csv71106.csv');
trans.Properties.VariableNames={'Date','Name','Amount'};
trans(trans.Amount > 0, :) = [];
should work.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Workspace Variables and MAT Files finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!