Row index exceeds table dimensions.
22 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Tommy
on 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 Comments
More Answers (0)
See Also
Categories
Find more on Workspace Variables and MAT Files in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!