Hey everyone!
Ive been trying to solve "the envelope problem" i uploaded a few days ago and ive made huge progress. However im now stuck on some silly little thing. I need to find the parametric equation for circles radius (later many circles will be drawn with that).
My code so far is :
syms a b p x y L
F = [p/2,0];
xpara = [x sqrt(2*p*x)];
eqn1 = a*F(1,1)+b == 0;
eqn2 = a*x+b == xpara(1,2);
eqns = [eqn1 eqn2];
%L - lambda.
eqns = [a*F(1,1)+b == 0, subs(a*x+b,x,L) == subs(xpara(1,2),x,L)];
S=solve(eqns,[a b],'ReturnConditions',true);
S.a;
S.b;
sirge =simplify(S.a*x+S.b);
loikepunktx = solve(sirge==-xpara(1,2),x,'ReturnConditions',true);
%sirge is a line equation
loikepunktx.x=loikepunktx.x(2,1);
loikepunktx.x;
sirge1 = simplify(S.a * loikepunktx.x + S.b);
sirge1;
LP = [loikepunktx.x, sirge1];
%Center = KP
KP = subs(simplify((xpara + LP)/2),x,L);
%ok so far
xpara;
KP;
In wolframalpha the solution would be
pR = Simplify[(xpara - KP) . (xpara - KP)] /. x -> \[Lambda]
and it gives the answer :
In MatLab however, im always getting a dot (i.e (x,y)) not the formula. Matlab doesnt simplify it like wolfram but the answer should be similar/ simplifiable to that form.
Probably going to be asking a few more questions while trying to progress but i am close to the end :)
Edit: i just did it the easy way:
R = subs(sqrt((xpara(1,1)-KP(1,1))^2+(xpara(1,2)-KP(1,2))^2),x,L)
But it doesnt give the same answers as in wolfram. The wolframalpha answer is squared of what matlab gives me. I dont know whether my WA has a mistake in it or my matlab code.

댓글 수: 3

darova
darova 2021년 5월 27일
MATLAB has weak symbolic toolbox. WHat about numerical approach?
Stefan Juhanson
Stefan Juhanson 2021년 5월 28일
Can not be approached numerically since in the end i need to plot a group of circle shaped envelopes. Theres a parabola y^2 = 2*p*x. And on its focalchords are the diameters of the sought circles. The task is to get the equation for the circles envelope group and plot it. The end plot looks like this:
But this was done in wolframalpha so now i am trying to convert the code into MatLab
Stefan Juhanson
Stefan Juhanson 2021년 5월 28일
I found the reason why i get it squared in wolfram alpha. I used scalar multiplication in WA and if a vector is multiplied by itself it gives R^2 not R.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 MATLAB에 대해 자세히 알아보기

질문:

2021년 5월 26일

댓글:

2021년 5월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by