reading files and data into matlab

2 visualizzazioni (ultimi 30 giorni)
Hale
Hale il 16 Lug 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 Commenti
Jan
Jan il 16 Lug 2013
What exactly is a "time step" here?
Hale
Hale il 16 Lug 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.

Accedi per commentare.

Risposte (3)

Jan
Jan il 16 Lug 2013
Modificato: Jan il 16 Lug 2013
I suggest to take a look into the FileExchange and use one of the many recursive file importers.

Grzegorz Knor
Grzegorz Knor il 16 Lug 2013
Enter to subfolders: cd
Exit from subfolders cd ..
Read files: importdata

Hale
Hale il 17 Lug 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 Commento
Jan
Jan il 18 Lug 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.

Accedi per commentare.

Categorie

Scopri di più su Startup and Shutdown in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by