필터 지우기
필터 지우기

Why do I receive a "Run-time error '9': Subscript out of range" error when passing a matrix to MATLAB using Excel Link?

조회 수: 3 (최근 30일)
I created a matrix in VBA and attempted to pass it into MATLAB in the following way:
Sub MatlabTest()
matlabinit
Dim TestArray(2, 2) As Double
TestArray(0, 1) = 1
TestArray(0, 0) = 1
TestArray(1, 0) = 1
TestArray(1, 1) = 1
mlputvar "MLTestArray", TestArray
End Sub
However, this caused the following error:
Run-time error '9':
Subscript out of range

채택된 답변

MathWorks Support Team
MathWorks Support Team 2009년 6월 27일
VBA variables must be 1-indexed in order to be successfully passed to MATLAB via Excel Link. For example:
Dim mldata(1 To 2, 1 To 2) As Double
mldata(1, 1) = 2
mldata(1, 2) = 5
mldata(2, 1) = 6
mldata(2, 2) = 9
'Put variable into MATLAB
MLPutVar "y", mldata

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Export to MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by