Let a1=[3.698247068550237,7.396494137100475]
Let a2=[-0.315547526817319,-0.105392873956985]
Hw to find the random numbers in the following code
arr(i).Position=unifrnd(a2,a1,10);
The above is not working

댓글 수: 4

Rik
Rik 2021년 1월 11일
What are you trying to do? You want 10 values, but you only specify 2 ranges.
Kanika Bhalla
Kanika Bhalla 2021년 1월 11일
I want a2 should generate one randon no, a1 should generate one random no and then a new range should form and i should be able to get 10 nos between that range.
Rik
Rik 2021년 1월 11일
So you want some sort of recursive behavior? That is not what that function does, so if you want it, you will have to write it.
It is still not quite clear to me what you want, so I can't help you write it.
Kanika Bhalla
Kanika Bhalla 2021년 1월 11일
i want a random no from a1
let
a1=4 (generated by random function)
a2=-0.2 (generated by random function)
then
arr(i).Position=unifrnd(-0.2,4,10);

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

 채택된 답변

KALYAN ACHARJYA
KALYAN ACHARJYA 2021년 1월 11일
편집: KALYAN ACHARJYA 2021년 1월 11일

0 개 추천

"I want a2 should generate one randon no, a1 should generate one random no and then a new range should form and i should be able to get 10 nos between that range"
a1=[3.698247068550237,7.396494137100475];
a2=[-0.315547526817319,-0.105392873956985];
a1_rand=a1(1)+(a1(2)-a1(1))*rand(1)
a2_rand=a2(1)+(a2(2)-a2(1))*rand(1)
val_data=a1_rand+(a2_rand-a1_rand)*rand(10,1)
Result:
a1_rand =
5.0835
a2_rand =
-0.1176
val_data =
4.5689
4.9690
4.0361
1.1713
0.6007
2.5884
4.7619
1.3051
4.1624
1.0135

댓글 수: 3

Kanika Bhalla
Kanika Bhalla 2021년 1월 11일
thanks a lot
KALYAN ACHARJYA
KALYAN ACHARJYA 2021년 1월 11일
편집: KALYAN ACHARJYA 2021년 1월 11일
Please note, the answer has been updated.
It's my pleasure
Kalyan
Kanika Bhalla
Kanika Bhalla 2021년 1월 11일
Thanks a lot

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

추가 답변 (0개)

카테고리

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

질문:

2021년 1월 11일

댓글:

2021년 1월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by