Effacer les filtres
Effacer les filtres

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

2 vues (au cours des 30 derniers jours)
Zi
Zi le 4 Mar 2023
Commenté : Zi le 4 Mar 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.

Réponse acceptée

Walter Roberson
Walter Roberson le 4 Mar 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.
  1 commentaire
Zi
Zi le 4 Mar 2023
Thank you so much @Walter Roberson. You solution worked by adding a cell2mat function for Sigma.

Connectez-vous pour commenter.

Plus de réponses (0)

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by