フィルターのクリア

How do i band a vector into sized brackets

3 ビュー (過去 30 日間)
Nick Keepfer
Nick Keepfer 2018 年 2 月 13 日
コメント済み: Star Strider 2018 年 2 月 13 日
I have a matrix R(i,j), where R(i,:) gives the positions of several objects at a given timestep j.
Say I have at a given timestep R(i,:) = [1 2 3 4 5 6 7] and I wish to create bands where I could collect terms say between 1-3 and 4-7.
i.e Something that would pull R(i,j) into two seperate arrays where one contains the values between 1-3 and another with the values 4-7, keeping the timesteps intact.
Can anyone think of an easy way to do this?
Thanks in advance :)

採用された回答

Star Strider
Star Strider 2018 年 2 月 13 日
I am not certain what you are referring to.
Two possibilities:
R(i,:) = [1 2 3 4 5 6 7];
V1{i} = R(i, (R(i,:)>=1) & (R(i,:)<=3)) % Testing For Values (Cell Array)
V2{i} = R(i, (R(i,:)>=4) & (R(i,:)<=7)) % Testing For Values (Cell Array)
X1(i,:) = R(i,1:3) % Addressing Columns
X2(i,:) = R(i,4:7) % Addressing Columns
The first set test for element values within the range.
The second set simply addresses the appropriate columns. Note that you can do that with the entire matrix at once, rather than row-by-row.
  2 件のコメント
Nick Keepfer
Nick Keepfer 2018 年 2 月 13 日
The former is what I wanted, thank you very much, works like a dream!
Star Strider
Star Strider 2018 年 2 月 13 日
As always, my pleasure!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by