It is possible to find sequences over the 3rd dimension for each element in Matlab? Lets say I have these matrix 3x3x5
1 1 0
A(:,:,1) = 0 0 1
1 1 1
1 1 0
A(:,:,2) = 0 0 1
1 0 1
0 0 0
A(:,:,3) = 1 1 0
0 0 0
1 0 0
A(:,:,4) = 1 0 1
1 1 1
1 1 1
A(:,:,5) = 0 0 1
0 1 0
Now I want to finde sequneces lets 1's two time in a row over the 3rd dimension, so I get the result:
2 1 0
result = 1 0 2
1 1 1
Antway to do that?

답변 (2개)

Matt J
Matt J 2019년 1월 14일
편집: Matt J 2019년 1월 14일

0 개 추천

k=ones(1,1,2)/2;
result = sum( convn(A,k,'valid')>.999 ,3 );

댓글 수: 2

Jonas Damsbo
Jonas Damsbo 2019년 1월 14일
Where are you putting the value in the sum you want to find the sequence with?
Matt J
Matt J 2019년 1월 14일
편집: Matt J 2019년 1월 14일
In general, it would be,
k=ones(1,1,N)/N;

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

Andrei Bobrov
Andrei Bobrov 2019년 1월 14일
편집: Andrei Bobrov 2019년 1월 14일

0 개 추천

k = reshape([1,1,0],1,1,[]);
result = sum(convn(A,k,'same')==2,3);

댓글 수: 1

Jonas Damsbo
Jonas Damsbo 2019년 1월 14일
If now the value I want to find a sequnece for must be >10. How did I do that?

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

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

질문:

2019년 1월 14일

편집:

2019년 1월 14일

Community Treasure Hunt

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

Start Hunting!

Translated by