Selecting multiple data ranges

1 回表示 (過去 30 日間)
Binu
Binu 2020 年 12 月 15 日
コメント済み: Binu 2020 年 12 月 15 日
Hi,
This may be a simple thing, but I canot figure it out. This is simply something what I want to do ;
A1=(1:100)';
A2=(101:200)';
A3=[A1(1):A2(1),A1(2):A2(2),A1(3):A2(3),A1(4):A2(4), .............., A1(12):A2(12)]';
Is there any easy way to get this done rather than writing the long line with all 1 to 12 elements?
Appreciate your help
Thank you

回答 (1 件)

Matt Gaidica
Matt Gaidica 2020 年 12 月 15 日
編集済み: Matt Gaidica 2020 年 12 月 15 日
Do you need A1 and A2?
A3 = repmat(1:100,12,1) + transpose(repmat(0:11,100,1));
or
A3 = bsxfun(@plus,0:11,transpose(1:100));
  1 件のコメント
Binu
Binu 2020 年 12 月 15 日
Hi Matt,
Thank you for the reply.
I think my previous question was not very clear to get an answer in a way that I need.
If I put the numbers here....
A1=16745, 106274, 118049, 121015, 134331, 232569, 320928, 389473, 426957, 457992, 463514, 474278
A2=19343, 107752, 118528, 121693, 134349, 233340, 321452, 390241, 427364, 459020, 466512, 474401
So each pair (A1(1) : A2(1) ) represents a data range.
A3=[A1(1):A2(1),A1(2):A2(2),A1(3):A2(3),A1(4):A2(4), .............., A1(12):A2(12)]';
Is there any easy way to get A3 done rather than writing the long line with all 1 to 12 elements of A1 and A2?
Appreciate your help
Thank you

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

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by