I want to generate a fixed percent of random points on a straight line joining two points.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
SUSHMA MB
am 3 Aug. 2016
Bearbeitet: SUSHMA MB
am 3 Aug. 2016
I want to generate 5 percent of the randomly generated numbers in a fixed straight line equation. For example, i have two points (x1, y1) and (x2, y2), and now i have drawn a straight line between the two points, with the help of straight line equation. Now i want 100 random numbers to be generated out of which 5 percent of those random numbers should fall in the straight line that is joined between the two points.
5 Kommentare
Akzeptierte Antwort
Torsten
am 3 Aug. 2016
Instead of generating 100 random numbers, use "rand" to generate 5 random numbers on [0:1] and set the points to
lambda=rand(5,1);
x=x1+lambda*(x2-x1);
y=y1+lambda*(y2-y1);
Best wishes
Torsten.
5 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Random Number Generation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!