Converting an array slicer to Python
조회 수: 4 (최근 30일)
이전 댓글 표시
I have this code in MATLAB (attached below) and wondered how I'd go about converting it to Python seeing as it keeps giving me an error "TypeError: only integer scalar arrays can be converted to a scalar index"
l0= -200
hi = 20
x = ones(27000, 1);
udata = ones(27000, 10);
x1 = x((x>lo)&(x<hi));
u1 = udata((x>lo)&(x<hi), :);
댓글 수: 0
채택된 답변
추가 답변 (1개)
sam
2023년 4월 17일
This error message suggests that a function or operation is expecting an integer scalar index (single integer) as an index, but is instead receiving an array or a non-integer value. This can occur when attempting to index or slice an array with a non-integer or non-scalar value. To resolve this error, ensure that the index being used is a single integer and not an array or non-integer value. If working with arrays, consider using integer indexing or slicing methods to access specific elements or subsets of the array.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Call Python from MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!