Row index exceeds table dimensions.
22 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Youcef Kara
el 2 de Abr. de 2020
Respondida: Tommy
el 2 de Abr. de 2020
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 comentarios
Respuesta aceptada
Tommy
el 2 de Abr. de 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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Workspace Variables and MAT Files en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!