Handle Class Behavior: Looping through an object array

조회 수: 5 (최근 30일)
Peter
Peter 2014년 5월 9일
편집: Peter 2014년 5월 9일
Hello, I am fairly new to MATLAB and am building a GUI that loads large Excel files of raw data and allows the user to easily pull out "encrypted" information, perform calculations, filter, and plot. I am adding a feature that will allow the user to load multiple files at the same time - so, the GUI will perform the same initial processing on all files and then allow the user to quickly switch between file data in the interface.
I experimented with creating classes because I wanted to have better organization of the user input, methods to automatically set up the "encryption" information, and then ultimately have another class whose instances would represent the processed data from individual files.
When the user presses the button to extract the data(perform initial processing), I have the code create an object array (LogFiles) with size equal to the number of files selected. The object array is of class "Log3D", a handle class I created.
LogFiles(selected.nFiles,1) = Log3D;
My code loops through the number of files and performs two "Log3D class" methods on each file, here is the abridged portion:
for nFiles = 1:selected.nFiles
extractlogdata3D(LogFiles(nFiles,1),selected,nFiles);
bucketlogdata3D(LogFiles(nFiles,1),selected,nFiles);
end
My problem is that I don't quite understand the behavior of my handle class "Log3D', especially when I have an object array created of multiple instances. The result of my code is that the first file object (LogFiles(1,1)) loads properly and is processed properly - the proper data is extracted from the first file and saved into LogFiles(1,1) - but, upon the second/third/etc iteration, the second file object is loaded but the processed data is not saved to the class object like I think it will be. So, LogFiles(2,1) does not have any data saved to it in the end.
Can anybody help me understand my problem? It would be much appreciated!!! Peter A
  댓글 수: 2
Roberto
Roberto 2014년 5월 9일
please upload your class definition and your implementation (or at least part of them) so we can understand the problem better!
Peter
Peter 2014년 5월 9일
편집: Peter 2014년 5월 9일
I may have figured out the problem...it seems that passing a reference of the object from the object array as the input was not working, whereas passing the whole object array as the input to the method, and changing the method code to support this, seems to work.
Input to function before: LogFiles(nFiles,1) ---didnt work
Input to function now: LogFiles -----works

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Whos에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by