MATLAB Answers

Generation of random number which needs to be passed to an array

조회 수: 1(최근 30일)
Ganesh Kini
Ganesh Kini 15 Jun 2020
답변: Rik 15 Jun 2020
I have 2 variables named A and B
A has the range from -0.2 to 2.2
B has the range from -3.2 to 0.2
I need all the possible to combinations of A and B in 0.1 steps
for example
0.1 0.2
-0.1 -0.3 and so on
How do I randomly generate this?
  댓글 수: 2
Ganesh Kini
Ganesh Kini 15 Jun 2020
Thank you for your reply
I want all the sets of randomly mixed values and then I need to iterate them
So, there are two questions
1) How do I randomly pick one set of A and B and then pass it on the array?
2) How do I iterate all the sets of values without using for loop?

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


Rik 15 Jun 2020
You can generate all combinations and mix them up like this:
Now you can feed it to your next function. Whether you are able to avoid for-loops depends on what function you are trying to call. (and it may not be the optimal strategy to do so at any cost)

Community Treasure Hunt

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

Start Hunting!

Translated by