How to import a txt file into matlab?

3 vues (au cours des 30 derniers jours)
absomnia48
absomnia48 le 30 Déc 2016
Commenté : absomnia48 le 30 Déc 2016
Hi,guys.I have to write a code that reads a .dat file which contains weather stats for NYC.I' ve used -load file_name.txt- function but got an error.I also have to rearrange that dat file and save that new file as another dat file.Thanks
  5 commentaires
Star Strider
Star Strider le 30 Déc 2016
The ‘.dat’ file seems to be what you were having problems with. You have (apparently copied and pasted) the data in the ‘NYCtemp.txt’ file into your code.
What specifically do you want help with? If you need help with the ‘.dat’ file, please attach it and tell us what you want to do with it.
absomnia48
absomnia48 le 30 Déc 2016
This is the file I have to work with.I have to create a .dat file in Matlab exacly like this txt file.Then I have to rearrange the file so that months run vertically and years run horizantally.The code I wrote above is for the first part of my problem.(creating the .dat file).Thank you.

Connectez-vous pour commenter.

Réponses (1)

John D'Errico
John D'Errico le 30 Déc 2016
So learn to use one of the many tools to read a file. Start with textread, or more basic tools like fopen, fread. Then learn about how to save a file. Again, lots of tools, starting with save.
We don't do your work for you though. That is your job. Anyway, you have not asked a clear question that tells anybody anything about the file, or what error you got. So we cannot possibly help you more here. The crystal ball is so foggy today that we cannot see into your mind or your computer.

Catégories

En savoir plus sur Standard File Formats dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by