Date: Feb 28, 2013 2:14 AM
Author: Yair Altman
Subject: Re: Exporting MATLAB data in real time to Microsoft Excel 2007/2010

"Paolo" wrote in message <kegvjo$crd$1@newscl01ah.mathworks.com>...
> Hi,
>
> I am trying to export some MATLAB data (which changes in real time through a bluetooth sensor) but I am having trouble with errors.
>
> One method was to use ddeinit and ddepoke:
>
> channel = ddeinit('excel','control.xls');
>
> rc = ddepoke(channel, 'r1c1', mean(openmotion1));
>
>
> However after 30 secs it would give me the following error message:
>
> Error using ddepoke
> The first argument 'channel' is not valid.
>
> Error in btcallback (line 35)
> rc = ddepoke(channel, 'r1c1', mean(openmotion1));
>
> Error in instrcb (line 36)
> feval(val{1}, obj, eventStruct, val{2:end});
>
> So instead, I try to use xlswrite but I am not sure how to export the data in real time using this function. Would I have to use ActiveX? And if so, could someone please enlighten me on how to do so?


xlswrite starts a dedicated Excel process each time it is invoked, so it is hardly performant. Instead, use xlswrite1 or officedoc from the File Exchange, both of which keep Excel open and communicate directly with it, which should be fast enough for your needs.

Related: http://undocumentedmatlab.com/blog/fixing-matlabs-actxserver/

Yair Altman
http://UndocumentedMatlab.com