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!