passing a file to the timer function
Mostra commenti meno recenti
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 Commenti
Geoff Hayes
il 2 Ago 2017
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
il 2 Ago 2017
Patrick Lydon
il 3 Ago 2017
Risposta accettata
Più risposte (1)
KL
il 3 Ago 2017
You need to get the UserData from the timer object inside your timer function.
filetoRead = get(TimerH, 'UserData');
Categorie
Scopri di più su Scope Variables and Generate Names in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!