reading files and data into matlab

2 vues (au cours des 30 derniers jours)
Hale
Hale le 16 Juil 2013
Hi,
I'm very new to matlab coding and I hope that you guys can help me with this simple matlab code. I'm having trouble in reading some files from different directories. The following screen shot shows the location of the files that I want to read.
In processor1 directory, there are files for each time step. I need to read all the files in those directories except directory 0 and constant which has to be skipped. And then the files for each variable e.g. alpha1 should be imported and finally I want to sort them in ascending order.
I have tried the following but it only gives the name of the foldes at each time step. How to I enter the subfolder and read the files?
I really appreciate any ideas.
  2 commentaires
Jan
Jan le 16 Juil 2013
What exactly is a "time step" here?
Hale
Hale le 16 Juil 2013
The data are given for 120 sec and there is an output every 0.1 sec i.e. 0.1 is the time step. The time vector is 0:0.1:120.

Connectez-vous pour commenter.

Réponses (3)

Jan
Jan le 16 Juil 2013
Modifié(e) : Jan le 16 Juil 2013
I suggest to take a look into the FileExchange and use one of the many recursive file importers.
  1 commentaire
Hale
Hale le 16 Juil 2013
Thanks, I'll have a look.

Connectez-vous pour commenter.


Grzegorz Knor
Grzegorz Knor le 16 Juil 2013
Enter to subfolders: cd
Exit from subfolders cd ..
Read files: importdata

Hale
Hale le 17 Juil 2013
Hi again,
I have now solve the problem with accessing the folder but I still have problem reading the files. When I call the readFvScalarField function it returns a vector of NaN which means that it couldn't find the files with the name 'boundaryFlux_outlet'. It is really weird since the vector 'files' contains the files with the name 'boundaryFlux_outlet'. Am I doing anything wrong in entering the specific folder or reading the files?
Thanks a lot
  1 commentaire
Jan
Jan le 18 Juil 2013
Please do not post questions in the section for answers. Adding the source code as formatted code is much better than adding a picture, because we can copy&paste the code to suggest improvements.
When you omit the brute clearing header containing the "clear all", you could use the debugger to check, what's going on in your code. Set a break point in the first line, step through the code line by line and check the value of the local variables. But unfortunately the frequently occurring "clear all" deletes all break points. Ugly. So remove it.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Startup and Shutdown 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