필터 지우기
필터 지우기

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

조회 수: 2 (최근 30일)
Zi
Zi 2023년 3월 4일
댓글: Zi 2023년 3월 4일
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.

채택된 답변

Walter Roberson
Walter Roberson 2023년 3월 4일
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
Zi
Zi 2023년 3월 4일
Thank you so much @Walter Roberson. You solution worked by adding a cell2mat function for Sigma.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by