passing a file to the timer function
이전 댓글 표시
Hi, I am having trouble with my program. I am receiving data from 8 channels in one file. At the beginning of the program, I open up the file and parse through it, making an array for each of the channels. Then I plot these values on one graph. Every 100ms the data is updated. I would like for my graph to update as my data is updated. I am using a timer function to try to accomplish this. Everytime the timer function is called, it opens the updated file, parses through the data, makes the 8 arrays for the 8 channels, then updates the graphs and repeats repeats repeats.
The problem I am currently having is that after the first callback of the timer, the command window says "Reference to a cleared variable filetoRead." So obviously the file has been cleared and its trying to read a cleared file. How do I pass the "filetoRead" to the callback function. I tried using UserData but this didnt seem to work. Is there an easier way to refresh the file that i had once previously opened? I have asked this question two times before on the forum and no one answered it for me.
댓글 수: 3
Geoff Hayes
2017년 8월 2일
Patrick - please post some of your code so that we can get an idea of what you have written that leads to the above problem. Are you running this code from within a GUI or as a script? Is data being appended to the file or is the file being overwritten with new data?
Patrick Lydon
2017년 8월 2일
Patrick Lydon
2017년 8월 3일
채택된 답변
추가 답변 (1개)
KL
2017년 8월 3일
You need to get the UserData from the timer object inside your timer function.
filetoRead = get(TimerH, 'UserData');
카테고리
도움말 센터 및 File Exchange에서 Scope Variables and Generate Names에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!