MATLAB: How to generate random points in a line generatelinespoints Dear All, I need to generate points on a line. can anyone help me please with any suggestion, I found just one and I need at least 10 points. Thanks for any help. Regards, Imola Best Answer For each line (edge) of the polyhedron you can write it's equation as(y - y1) = (y1 - y2)(x - x1)/(x1 - x2)So in case of edge from vertex (0, 2) to (1, 0) you can generate it as -x = (1 - 0) * rand(n,1) + 0 ; %(x2-x1)*(n random number)+x1y = (2 - 0)/(0 - 1) * (x - 0) + 2 ; % (y1-y2)/(x1-x2)*(x-x1) + y1Here 'n' is the number points you need to generate on the edge. You can do it for each pair of adjacent vertices in a loop. Related SolutionsMATLAB: Place array in a matrix Perhaps I'm misunderstanding but if x = [1.0000 0 0.5000 1.0000 0.5000 1.5000 0 -1.0000 -1.0000 1.0000 0.5000 -1.0000];which is a 6x2 array, then wouldn't x*x'be the desired 6x6 array? MATLAB: Symbolic simplification issue with exact division of polynomial by monomial Sometimes, you have to lead it gently by the hand if you want it to do everything:syms x1 x2 y1 y2 f = ((x1 + y2 - x1*y2)*(- x2^2*y1 + x2^2 + x2*y1^2 - y1^2)*(2*x1 + x2 + y1 - x1*x2 - x1*y1 - 1))/(x2 - y1);f1 = expand(f);f1 = simplify(collect(f1))f1 =(x1 + y2 - x1*y2)*(x2 + y1 - x2*y1)*(2*x1 + x2 + y1 - x1*x2 - x1*y1 - 1)Is that the sort of result you want? Related QuestionHow can i fix this error ? Failure in initial user-supplied objective function evaluation. FMINUNC cannot continue.How to convert the X & Y value in a matrix formatPlace matrix in array part 2
Best Answer