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 CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by