How can I pass a variable from MATLAB to Excel using DDE by passing only the first cell of the Excel sheet?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
MathWorks Support Team
am 27 Jun. 2009
Bearbeitet: MathWorks Support Team
am 14 Okt. 2021
How can I pass a variable from MATLAB to Excel using DDE by passing only the first cell of the Excel sheet?
I would like to do something like this:
channel = ddeinit('excel', 'sheet1');
data = rand(5);
range = 'r1c1' % I do not know the end row and column of data
rc = ddepoke(channel, range, data) % This will only populate one cell not the whole data into Excel
Akzeptierte Antwort
MathWorks Support Team
am 11 Okt. 2021
Bearbeitet: MathWorks Support Team
am 14 Okt. 2021
There is no direct API available to do this. You can write a small function to achieve your goal. For example:
function rc = ddepokeUnlimited(channel, startRow, startCol, data)
% This function will take in the startRow number and start Column
% number and write the data provided to the channel using DDE. This
% function will calculate the size range internally
[m n] = size(data);
endRow = startRow + m -1;
endCol = startCol + n -1;
range = ['r' num2str(startRow) 'c' num2str(starCol)...
':r' num2str(endRow) 'c' num2str(endCol) ];
rc = ddepoke(channel, range, data);
Note that MATLAB supports ActiveX protocol. You can use MATLAB as an ActiveX server or as an ActiveX client. You have more functionality available via ActiveX as compared to DDE. Please refer to Chapter 7 of the External Interfaces Users Guide for more information. You can view the HTML format of this section at the following URL:
https://www.mathworks.com/help/matlab/matlab_external/supported-client-server-configurations.html
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu ActiveX finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!