Why does MATLAB round-off my data when obtaining data from Excel using DDE protocols?

7 views (last 30 days)
I am making a DDEREQ and/or DDEADV call from MATLAB to get data. What I need, however is for MATLAB to not round the data to one decimal place. If I use Excel to make a DDE hotlink, it gives me the full result.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 20 Oct 2017
The round-off behavior is a limitation of MATLAB when interfacing with Excel using the DDE protocol.
NOTE: As of MATLAB 5.3.1 (Release 11.1) DDE has been stabilized. That is, we are no longer developing this feature. If you want to access other Windows applications, use ActiveX.
Documentation on ActiveX can be found in our documentation at:
A simple example is provided below on how to use ActiveX to obtain data from the first cell of the first sheet in an Excel Workbook. Note the use of the FORMAT LONG, so that the data will not be truncated.
 
%Open An Excel Server
excel=actxserver('Excel.Application');
get(excel)
%Open an Already Existing WorkBook
workbooks=excel.workbooks
h=invoke(workbooks,'open','H:\Documents\Attach\Cases\work\example.xls') %Direct to location of *.xls
%Make First sheet Active
sheets=excel.ActiveWorkBook.Sheets;
sheet1=get(sheets,'Item',1);
invoke(sheet1,'Activate');
%Get Handle to an Active Sheet
activesheet=excel.Activesheet;
%Get A value from a certain cell
range=get(activesheet,'range','a1')
format long %Set MATLAB format so that it does not truncate value
value=range.value

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!