array slicing in Matlab

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 comentarios

for i=1:length(pos)
if i < (data - SW+1);
WF = data(i:i+ SW*2);
end
James Tursa
James Tursa el 6 de En. de 2022
Editada: James Tursa el 6 de En. de 2022
Looks like a set of parens is missing also:
(data - (SW+1))
Walter Roberson
Walter Roberson el 2 de Feb. de 2022
You sent me email, but my reply was rejected by gmail ??

Iniciar sesión para comentar.

Respuestas (1)

Navya Singam
Navya Singam el 10 de En. de 2022

1 voto

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.

Categorías

Productos

Versión

R2021a

Preguntada:

el 6 de En. de 2022

Comentada:

el 2 de Feb. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by