Accessing a structure from a script file
古いコメントを表示
I am using a piece of software which processes data and exports it to Matlab as a structure within a mat file. I am tryng to write a script which will extract the data for further processing using Matlab.
The software automaticaly names the structure as a variation of the filename by adding the leading character 'N'. For example the file test.mat will contain the structure with the name Ntest. The structure itself is (1xch) format where 'ch' is the number of data channels exported. and contains 10 fields giving information about the data channel. The data itself is stored as single precision vector '.data'
I have been able to access the data ok using command line instructions, but wish to make use of a script to save time. Unfortunately all examples of structures that I have come across use command line processing to access them.
I have tried loading the mat file using the commands;
[filein,pname]=uigetfile('*.*','select');
load (filein);
but cannot get a form of syntax to enable me to generate the structure name to progress further in accessing the structure itself.
Am I using the correct approach or is there a better way of accessing a structure contained within a mat file using a script ?. Any help on the correct syntax or approach would be appreciated.
回答 (3 件)
Sean de Wolski
2012 年 10 月 29 日
I would use:
S = load(filein)
So that you have the structure/variable named in a 'known' variable.
Star Strider
2012 年 10 月 29 日
編集済み: Star Strider
2012 年 10 月 29 日
I'm not certain that I completely understand your problem. I suggest that you might be able to do what you want using load with an output argument, for example:
S = load(filein);
Then S should have the information you're interested in.
Chris ODonnell
2012 年 10 月 29 日
編集済み: Chris ODonnell
2012 年 10 月 29 日
0 投票
1 件のコメント
Sean de Wolski
2012 年 10 月 29 日
It shouldn't be any different in a script than from the command line. If you run commands at the command line, the exact same commands should work when in a script and run essentially at the command line.
カテゴリ
ヘルプ センター および File Exchange で Data Import and Analysis についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!