array slicing in Matlab

조회 수: 258 (최근 30일)
Thanaa AlShawaf
Thanaa AlShawaf 2022년 1월 6일
댓글: Walter Roberson 2022년 2월 2일
Hello everyone,
I tried to slice my data from the from position where threshold is crossed to end of window using Python and I worked but when I tried to write it in matlab, Unfortnetly I encountred some errors.
Python code:
for i in pos:
if i < data.shape[0] - (SW+1):
Waveform = data[i:i+SW*2]
Matlab code:
for i=1:length(pos)
if i < (data - SW+1);
WF = data(i,i+ SW*2);
end
  댓글 수: 3
James Tursa
James Tursa 2022년 1월 6일
편집: James Tursa 2022년 1월 6일
Looks like a set of parens is missing also:
(data - (SW+1))
Walter Roberson
Walter Roberson 2022년 2월 2일
You sent me email, but my reply was rejected by gmail ??

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

답변 (1개)

Navya Singam
Navya Singam 2022년 1월 10일
Hi,
MATLAB Version of the code would be
sizeOfData = size(data)
for i=1:length(pos)
if i < (sizeOfData(1) - (SW+1)); %% use size function to get the size of the matrix
WF = data(i:i+ SW*2);
end
size function returns a vector of number of elements in the row and column.

카테고리

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

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by