필터 지우기
필터 지우기

Storing values in vectors corresponding to a vector of indices

조회 수: 3 (최근 30일)
Safouane Chergui
Safouane Chergui 2017년 8월 10일
답변: Guillaume 2017년 8월 15일
Hello !
I have a vector that corresponds to a time domain signal. I have a second vector containing some values. The values in this second vector are represent some indices. I would like to save all values starting from the first value in the first vector till the value whose index is the first value in the second vector. After that, I would like to save all values going from the (first index+1) till the value whose index in the first vector corresponds to the second value in the second vector,etc.
What's the best way to accomplish this ?
NB: if the statement is not clear, please don't hesitate to ask for more explanation
  댓글 수: 2
dpb
dpb 2017년 8월 11일
Well, I hesitated...sorry. :)
I came back and reread trying to parse which first is which and was still unsuccessful...
How about showing a small sample dataset and the expected output and how you get from the first to the second? It should only require a couple of entries or so to illustrate I'd think...
Sangeetha Jayaprakash
Sangeetha Jayaprakash 2017년 8월 15일
Yeah - can you provide an example of both the vectors to illustrate what the desired output is?

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

답변 (1개)

Guillaume
Guillaume 2017년 8월 15일
If I understood correctly:
splitvectors = mat2cell(yoursignal, diff([0, yourindices, numel(yoursignal)]))

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by