How can I pass a variable from MATLAB to Excel using DDE by passing only the first cell of the Excel sheet?
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
MathWorks Support Team
il 27 Giu 2009
Modificato: MathWorks Support Team
il 14 Ott 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
Risposta accettata
MathWorks Support Team
il 11 Ott 2021
Modificato: MathWorks Support Team
il 14 Ott 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 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su ActiveX in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!