3

I want use matlab to get IBM price from yahoo price can get by

quote = fetch(yahoo, 'IBM', 'Last');
px = quote.Last;

Now I want to retrieve the data every minute from, for example, 9:00 am to 1:00 pm. I would like to use timer object to get my data.

However, I cannot figure out how to use it. What I can get is

t = timer;
t.ExecutionMode = 'fixedRate';
t.Period = 60;

especially the timerFcn, I don't get how to use it.

Hope someone can write me an example with this. Thanks

1
  • timerFcn is the function you ant to execute. Commented Jan 8, 2014 at 20:39

1 Answer 1

7

You need to write a callback function to use TimerFcn.

Let this be your main file, where you initiate the timer:

tmr = timer('ExecutionMode', 'FixedRate', ...
    'Period', 60, ...
    'TimerFcn', {@timerCallback});
start(tmr);

Then this would be your callback function, which would execute every time the timer count is complete (i.e. every 60 seconds in your example).

function timerCallback(hObj, eventdata)
    disp('timey-wimey');
end
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.