How do I plot parametric equations in Matlab?
Show older comments
I have the attached equations for lines r & s. I have used the below code to plot r but I can not plot s.
I need to find the value of a knowing that both lines intersect at one point. Find the coordinates of the intersection point.

1. How do I plot 's'?
2. Is my working for plotting 'r' correct?
>> t=-10:0.5:10;
>> x=3-t;
>> y=1+2*t;
>> z=-4+3*t;
>> figure(1)
hold on
plot3(x,y,z,'xr')
plot3(x,y,z)
hold off
grid on
xlabel('x axis')
ylabel('y axis')
zlabel('z axis')
4 Comments
Walter Roberson
on 4 Mar 2018
Given any particular lambda, your 3 equations for r lock down x, y, and z to single values. You can plot that easily.
Given any particular a, your 2 equations for s only give enough information to find two of the variables with relation to the third. That defines a line for each a rather than defining a point.
FortuitousMonkey
on 4 Mar 2018
Walter Roberson
on 4 Mar 2018
syms x y z a lambda
eqn = [x==3-lambda,y==1-2*lambda,z==-4+3*lambda,x+2*y+3*z==a,3*x-2*y+z==-a];
sol = solve(eqn);
sol.x, sol.y, sol.z, sol.lambda, sol.a
... all of which gets you one point, but is not enough to allow you to plot s independently as a line.
Consider
x + 2 * y + 3 * z == a
3 * x + 2 * y + z == -a
then from the first one,
x = a - 2 * y - 3 * z
substitute that into the second one:
3 * (a - 2 * y - 3 * z) + 2 * y + z == -a
which is
3*a - 4*y - 8*z == -a
which is
4*a - 4 * y - 8*z == 0
or
a - y - 2 * z == 0
for any given a value, that is only enough information to deduce
y = a - 2 * z
which gives you a relationship between y and z, but does not constrain z. You would need to plot using all z from -inf to +inf, and each z value would have a corresponding x and y point -- and this is the case for each a value.
FortuitousMonkey
on 13 Mar 2018
Edited: FortuitousMonkey
on 13 Mar 2018
Answers (0)
Categories
Find more on Calculus in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!