0

I am trying to read a dat file in MATLAB but my data is not correctly separated into columns. All of the data is in one single column.

I am not sure how to separate them into proper columns

What I am trying to do is to have the data separated into column like so:

Column A Column B
1 2
3 4

but what my file shows is:

Column A Column B
1 2
3 4
Emily
  • 1
  • 1
  • 1
    What does the dat file look like, exactly? Is it a text file? How are you reading the file? We need to see the file and the code. – Tim Roberts Jun 01 '23 at 17:16
  • i haven't tried to read it yet becuase I don't know how to fix the formatting. it is just a .dat file that should be in multiple columns but it instead is in only one column – Emily Jun 01 '23 at 17:20
  • We need a piece of code that reproduces this – Ander Biguri Jun 01 '23 at 17:22
  • 2
    See, here's the problem. It may be that the method you are using to read the file assumes the columns are separated by commas, when in fact the columns are separated by spaces. We can't tell that without (A) seeing the file and (B) seeing the command you use to read it. THAT'S why we ask. – Tim Roberts Jun 01 '23 at 17:26
  • also .dat is a generic file extension meaning that depending from which software it refers to it can have a slightly different structure so we cannot just guess it. – Ferro Luca Jun 02 '23 at 06:24
  • You'd better attach a runnable & minimal demo (code and data) to reproduce your issue. – Shannon Jun 03 '23 at 09:03

0 Answers0