MATLAB: How to generate say 100 points randomly in a square or rectangle create a squarepoints generation I want to generate 100 points in a square , which side length is 5 m. Best Answer x=rand(1,100)*5y=rand(1,100)*5scatter(x,y)ora=rand(2,100)*5scatter(a(1,:),a(2,:)) Related SolutionsMATLAB: I want to generate a fixed percent of random points on a straight line joining two points. Instead of generating 100 random numbers, use "rand" to generate 5 random numbers on [0:1] and set the points tolambda=rand(5,1);x=x1+lambda*(x2-x1); y=y1+lambda*(y2-y1);Best wishesTorsten. MATLAB: I have a straight line(X1,Y1) (X2,Y2). I want to know the coordinates of all the points present on the straight line. I have another random line along the straight line. I have to calculate the Mean Squared Error between the two lines. How do i do p1 = [0 0] ;p2 = [1 2] ;% get slope m = (p2(2)-p1(2))/(p2(1)-p1(1)) ;% get between points xi = p1(1):0.01:p2(1) ;yi = p1(2)+m*(xi-p1(1)) ;figurep12 = [p1 ;p2] ;plot(p12(:,1),p12(:,2),'r')hold onplot(xi,yi,'.b') Related QuestionGenerate random 3D coordinates in a cylinderDraw a line from 2 points and get x and y valuesHow to generate random points inside a sphere?Hello sir, i want to get the ‘sky’ from the sky and ‘building’ from the building from the following xml file. i want to get these two as text files.Creating lines of a random orientation and unit length in matlab
Best Answer