Borrar filtros
Borrar filtros

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

2 visualizaciones (últimos 30 días)
Zi
Zi el 4 de Mzo. de 2023
Comentada: Zi el 4 de Mzo. de 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.

Respuesta aceptada

Walter Roberson
Walter Roberson el 4 de Mzo. de 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 comentario
Zi
Zi el 4 de Mzo. de 2023
Thank you so much @Walter Roberson. You solution worked by adding a cell2mat function for Sigma.

Iniciar sesión para comentar.

Más respuestas (0)

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by