Info

This question is closed. Reopen it to edit or answer.

Can i use the "solve" function in this case?

1 view (last 30 days)
Orestes Bastos
Orestes Bastos on 25 Feb 2014
Closed: MATLAB Answer Bot on 20 Aug 2021
Hello, i'm working on a GUI and i'm having trouble finding the coordinates of a point between two other points using solve. I need to divide a line, a user set number of times, and put a text in it.
Also, if there was a way to interact with the lines properties it may help, as i need to break this lines in smaller ones.
I'm open to suggestions.
I'm using Matlab R2012b version!

Answers (1)

Walter Roberson
Walter Roberson on 25 Feb 2014
You do not need to solve() inside the loop. You do not need to loop there at all.
syms d x y
[sx, sy] = solve((y-Y)/(x-X) = m, (x-X)^2+(y-Y)^2 = d^2, x, y);
SX = subs(sx, d, dens * (1:ndd));
SY = subs(sy, d, dens * (1:ndd));
This will give you vectors of symbolic values, which you might later want to double(SX) for numeric use.
You have a difficulty that there are two pair of (x,y) for each d: if you change the sign of both (x-X) and (y-Y) then the ratio is the same and the sum of squares is the same, so there must be two solutions.

Community Treasure Hunt

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

Start Hunting!