How to get particular data from column of table in MATLAB

2 visualizaciones (últimos 30 días)
Dev Liya
Dev Liya el 30 de Dic. de 2021
Comentada: Rena Berman el 21 de Mzo. de 2022
i have this type of table. which is in the below image. and also upload the sample file which is "data.csv".
now I need only the row where this "LBNP:30" type of data is available in last column . please help. I am new to MATLAB.
  6 comentarios
Stephen23
Stephen23 el 18 de Feb. de 2022
Original question retrieved from Google Cache:
How to get particular data from column of table in MATLAB
i have this type of table. which is in the below image. and also upload the sample file which is "data.csv".
now I need only the row where this "LBNP:30" type of data is available in last column . please help. I am new to MATLAB.
Rena Berman
Rena Berman el 21 de Mzo. de 2022
(Answers Dev) Restored edit

Iniciar sesión para comentar.

Respuestas (2)

Stephen23
Stephen23 el 31 de Dic. de 2021
Editada: Stephen23 el 31 de Dic. de 2021
What you uploaded is not a CSV text file, it is an XLSX file with an incorrect file extension.
I fixed the file extension for you (attached).
T = readtable('data.xlsx')
T = 5×5 table
Var1 Var2 Var3 Var4 Var5 ____________________________ __________ ____ _____ ___________ {'2021-11-01T19:59:49.706Z'} 1.5005e+07 113 32962 {'LBNP:30'} {'2021-11-01T19:59:49.707Z'} 1.5007e+07 114 32805 {0×0 char } {'2021-11-01T19:59:50.041Z'} 1.534e+07 115 32654 {'LBNP:40'} {'2021-11-01T19:59:50.043Z'} 1.5342e+07 116 32568 {'LBNP:50'} {'2021-11-01T19:59:50.044Z'} 1.5344e+07 117 32564 {0×0 char }
X = cellfun(@isempty,T.Var5);
T(X,:)= []
T = 3×5 table
Var1 Var2 Var3 Var4 Var5 ____________________________ __________ ____ _____ ___________ {'2021-11-01T19:59:49.706Z'} 1.5005e+07 113 32962 {'LBNP:30'} {'2021-11-01T19:59:50.041Z'} 1.534e+07 115 32654 {'LBNP:40'} {'2021-11-01T19:59:50.043Z'} 1.5342e+07 116 32568 {'LBNP:50'}
  1 comentario
Stephen23
Stephen23 el 31 de Dic. de 2021
Editada: Stephen23 el 31 de Dic. de 2021
"what is return cellfun to X ?"
X is a logical array the same size as T.Var5, with TRUE where the cells of T.Var5 are empty:
"and what is the meaning of this line "T(X,:)= []" ?"
T(X,:)=[] uses logical indexing to remove every row of table T where X is TRUE.
Logical indexing is a very basic and important MATLAB concept:
"i cannot understand it. specially "= []"."
That is a special syntax that removes elements from any array:

Iniciar sesión para comentar.


Walter Roberson
Walter Roberson el 30 de Dic. de 2021
T = readtable('YourFileNameGoesHere.xlsx');
last_column = T{:,end};
  4 comentarios
Walter Roberson
Walter Roberson el 18 de Feb. de 2022
Although technically I could delete this answer, doing so would displease me. So.. NO.
Walter Roberson
Walter Roberson el 19 de Feb. de 2022
If someone else is imposing on your a requirement to have this question deleted, then have them send a request to Mathworks to have it removed, along with an explanation of why it "must" be removed -- and also along with a plan to compensate the volunteers for their work. The volunteers do not agree to become free private consultants.

Iniciar sesión para comentar.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by