Hi,
I am dealing with a spreadsheet which is linked to Bloomberg and therefore it is updating like every 1 min or so. I would like to find a way how i can automatically import the spreadsheet into a Matlab table every time the Spreadsheet data changes. Any suggestions how i can proceed on this issue?
best regards,

 채택된 답변

Iain
Iain 2014년 9월 15일

0 개 추천

It is possible to use a macro in excel that will tell matlab, in some way, if it has been updated.
It is also possible to just check the spreadsheet, from matlab, every "n" seconds. ("pause" & xlsread, being the commands you'd want)
It is also possible to control the spreadsheet's operation from matlab via an active x server.

댓글 수: 6

Paul
Paul 2014년 9월 15일
Hi lain, thanks for the fast reply. I think the second alternative is the most convenient for my use. Would you be so kind and elaborate a bit more on how to do this. (Sorry for my ignorance i am quite new to Matlab)
best regards,
I'd use a while loop:
while true
[numbers text rawdata] = xlsread(filename,sheetno); % reads 1 sheet out of the excel file
do stuff % do stuff here...
if something_happened
break % stop.
end
pause(55) % waits 55 seconds...
end
Paul
Paul 2014년 9월 15일
great, thanks I'll start with that.
Iain
Iain 2014년 9월 15일
tic & toc, or "now" or "clock" might give you better timing control than pause. Pick the right tool.
Paul
Paul 2014년 9월 15일
편집: Paul 2014년 9월 15일
tic & toc, or "now" or "clock" might give you better timing control than pause. Pick the right tool.
where would i put these commands you are referring to?
It depends what you're doing.
This:
tic
do stuff
a = toc;
Makes "a" store how long it took to "do stuff".
now & clock both return the current time, so you can calculate how long it took to:
a = now; or clock...
do_stuff
b = now; or clock...
time_taken = b-a;
With those you can make sure you only read the excel file at specific times. (say, once every minute, at 25 seconds.)

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

추가 답변 (0개)

카테고리

도움말 센터 및 File Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기

질문:

2014년 9월 15일

댓글:

2014년 9월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by