Ok, it seems Mathworks have made this quite a bit easier than it used to be.Hi,
thanks for your quick reply. I am actually a beginner in programming and matlab so I am not aware of the timer function. Below is what I am doing:
output_voltage = Measure_voltage (gdm)
dlmwrite(output_file, [time_stamp output_voltage], 'delimiter', '\t', 'newline','pc','-append');
So I am measuring the voltage and writing it in a text file. I want to do this every 10 seconds for say 30 minutes. How do I use the timer function. I looked up timer function in the help menu but am not able to figure it out. The data is always present at the output of the meter. Matlab makes the measurement everytime I call the function Measure_voltage.
Thank you.
v_timer = timer;
set(v_timer,'ExecutionMode','FixedRate')
set(v_timer,'Period',30)
set(v_timer,'TimerFcn','voltage_read')
start(v_timer)
stop(v_timer)
Sorry I missed this yesterday.Hello Dave,
I was able to run the program. My main program looks like this:
function output_with_timer ()
gdm = setup_gpib()
t = timer('ExecutionMode', 'fixedRate', 'Period', 10.0)
t.TimerFcn = {@Measure_voltage, gdm};
start(t)
This program captures voltage measurement and writes it to a text file every 10 seconds. This goes on forever. How do I use the stop timer command if I want to stop it after 20 minutes. So I want it to capture data every 10 seconds for 20 minutes and then stop. I was thinking of using a while loop. But I am not sure how it would work. Can you help me in this? How can I make a condition for it stop after 20 minutes or rather any time I want?
Thank you very much.