44 views (last 30 days)

Torsten
on 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.

Opportunities for recent engineering grads.

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

Start Hunting!
## 5 Comments

## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/298220-i-want-to-generate-a-fixed-percent-of-random-points-on-a-straight-line-joining-two-points#comment_383088

⋮## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/298220-i-want-to-generate-a-fixed-percent-of-random-points-on-a-straight-line-joining-two-points#comment_383088

## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/298220-i-want-to-generate-a-fixed-percent-of-random-points-on-a-straight-line-joining-two-points#comment_383091

⋮## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/298220-i-want-to-generate-a-fixed-percent-of-random-points-on-a-straight-line-joining-two-points#comment_383091

## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/298220-i-want-to-generate-a-fixed-percent-of-random-points-on-a-straight-line-joining-two-points#comment_383094

⋮## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/298220-i-want-to-generate-a-fixed-percent-of-random-points-on-a-straight-line-joining-two-points#comment_383094

## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/298220-i-want-to-generate-a-fixed-percent-of-random-points-on-a-straight-line-joining-two-points#comment_383105

⋮## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/298220-i-want-to-generate-a-fixed-percent-of-random-points-on-a-straight-line-joining-two-points#comment_383105

## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/298220-i-want-to-generate-a-fixed-percent-of-random-points-on-a-straight-line-joining-two-points#comment_383109

⋮## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/298220-i-want-to-generate-a-fixed-percent-of-random-points-on-a-straight-line-joining-two-points#comment_383109

Sign in to comment.