Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

How to remove rows which match some conditions in scv file?

3 vues (au cours des 30 derniers jours)
jintaek sung
jintaek sung le 17 Juin 2019
Clôturé : MATLAB Answer Bot le 20 Août 2021
Hi, I started to learn Matlab and am doing my thesis on finance.
I want to use only rows in the table which contain 10, 11 in collumn 3, so remove all other rows wichi do not contain 10, 11 in collum 3.
How can I code this from the start on Matlab?
Please let me know how to do! thank youScreen Shot 2019-06-17 at 4.58.37 PM.png
  1 commentaire
Geoff Hayes
Geoff Hayes le 17 Juin 2019
jintaek - what have you tried so far? Have you written the code to read the data from the csv file?

Réponses (1)

Suryaansh Mata
Suryaansh Mata le 18 Juin 2019
After importing the table into MATLAB language as an array of type double follow these steps -:
1) Run a loop on each row of the array/table. Since we would be deleting the rows during our operation, it is advisable to use a 'while' loop and put in the stopping criteria as counter = numel(array), i.e stop when the counter reaches the last element of the array(modified).
2) Put in an if condition check inside the loop for each row, i.e if ~(row(3)==10 || row(3)==11) delete the row, in order to delete the row, use array(counter) = [], where counter denotes the current row being looked at in the array.
These 2 steps should do the job.

Cette question est clôturée.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by