t1 range is 0.1 to 2 and t2 range is 0.1 to 2.....and t1+t2 should not be greater than 2

1 回表示 (過去 30 日間)
Sun Heat
Sun Heat 2018 年 4 月 10 日
編集済み: Torsten 2018 年 4 月 13 日
t1 range is 0.1 to 2 and t2 range is 0.1 to 2.....and t1+t2 should not be greater than 2
  4 件のコメント
Sun Heat
Sun Heat 2018 年 4 月 10 日
yes sir t1 and t2 are randomly generated number in the range of 0.1 to 2 and the total sum of t1 and t2 should be below 2 or 2.
Sun Heat
Sun Heat 2018 年 4 月 10 日
sorry should not be greater than 2

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

採用された回答

Birdman
Birdman 2018 年 4 月 10 日
t1=0:0.1:2;
t2=0:0.1:2;
t=t1+t2;
t(t>2)=[];
  7 件のコメント
Sun Heat
Sun Heat 2018 年 4 月 13 日
number which is greater than 2 it become zero but it also reflect the random number which sum is greater than two....plz reply
Torsten
Torsten 2018 年 4 月 13 日
編集済み: Torsten 2018 年 4 月 13 日
n=10;low=0.1;up=2;
t1=low+(up-low)*rand(1,n)
t2=low+(up-low)*rand(1,n)
t=t1+t2;
t1(t>2)=[];
t2(t>2)=[];
(t1(i),t2(i)) are the pairs you are looking for.
Best wishes
Torsten.

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

その他の回答 (1 件)

Torsten
Torsten 2018 年 4 月 10 日
Generate a pair of random numbers in the range [0.1:2].
Accept the pair if their sum is less or equal 2.
Repeat until you have generated enough feasible pairs.
Best wishes
Torsten.

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by