Filter löschen
Filter löschen

Operator '*' is not supported for operands of type 'handle.handle'.

2 Ansichten (letzte 30 Tage)
Zi
Zi am 4 Mär. 2023
Kommentiert: Zi am 4 Mär. 2023
I am using ActiveX to import data from an Excel file in an optimization model. There is one handle object created (Sigma variable in the code), is there anyway we can convert it to a matrix? (I got the error "Operator '*' is not supported for operands of type 'handle.handle'." for any math operations that I run).
Here is my code:
sheetname = sprintf('%d%d',k,x(k)) ;
exlSheet1 = exlFile.Sheets.Item(sheetname);
dat_range = ['A1:Y25']; % Read to the last row
sigma(:,:,k) = exlSheet1.Range(dat_range);
Temp = sigma(:,:,k)*2;
I appreciate your help in advance.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 4 Mär. 2023
You have to use the Value property of the Range
sheetname = sprintf('%d%d',k,x(k)) ;
exlSheet1 = exlFile.Sheets.Item(sheetname);
dat_range = ['A1:Y25']; % Read to the last row
ex_range = exlSheet1.Range(dat_range);
sigma(:,:,k) = ex_range.Value;
Temp = sigma(:,:,k)*2;
Note: I have almost no practical experience with this, so I am going by what other people have posted.

Weitere Antworten (0)

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by