NaNs when reading from table

56 views (last 30 days)
Abdulkarim Almukdad
Abdulkarim Almukdad on 22 Oct 2020
When I read the data attached matlab shows the numbers from row 133 until 204 as NaNs. everything workds fine if I edit the numbers from excel by using text to columns function from excel because the numbers are placed in the first column rather than being distributed on the columns. Moreover, I'm looking for a way to read the the numbers from line 133 until the cell that contains (0 0 0 0 0 0 0) which is in this case its the row number 205. The file is in DAT format but since matlab website doesn't accept that format I had to convert it to csv.
I have used the below code
% T=readmatrix('Pilot1_Drive2.csv');
% T1=T(133:204,1:56);
% x = T1(:,4) ;
% y = T1(:,3) ;

Answers (1)

Sudhakar Shinde
Sudhakar Shinde on 22 Oct 2020
As there are empty fields within your csv file, MATLAB read it as NAN(not a number).
Thought could be:
  1. Create a data in csv sheet effectively without any empty field to not get Nan's.
or
2. After reading file i.e 'readmatrix' function, Nan can be replaced with zeroes or empty ('').
  1 Comment
Abdulkarim Almukdad
Abdulkarim Almukdad on 22 Oct 2020
Thanks for your answer.
I don't care about the empty cells as you can see from my code, I only want to read the numbers from 133 to 204 and all the cells there contain numbers. However, those numbers are being read as NaN in matlab when I use readtable or readmatrix functions.

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!