reading files and data into matlab

2 ビュー (過去 30 日間)
Hale
Hale 2013 年 7 月 16 日
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 件のコメント
Jan
Jan 2013 年 7 月 16 日
What exactly is a "time step" here?
Hale
Hale 2013 年 7 月 16 日
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.

サインインしてコメントする。

回答 (3 件)

Jan
Jan 2013 年 7 月 16 日
編集済み: Jan 2013 年 7 月 16 日
I suggest to take a look into the FileExchange and use one of the many recursive file importers.
  1 件のコメント
Hale
Hale 2013 年 7 月 16 日
Thanks, I'll have a look.

サインインしてコメントする。


Grzegorz Knor
Grzegorz Knor 2013 年 7 月 16 日
Enter to subfolders: cd
Exit from subfolders cd ..
Read files: importdata

Hale
Hale 2013 年 7 月 17 日
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 件のコメント
Jan
Jan 2013 年 7 月 18 日
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.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by