Clear Filters
Clear Filters

How do I plot input equations from the user?

2 views (last 30 days)
Swati Umamaheshwaran
Swati Umamaheshwaran on 18 Sep 2017
Answered: KSSV on 18 Sep 2017
Please help. I would like to plot equations with the equation itself (e.g. x + y ==5)as user input. Also, how do I find the coordinates of the point of intersection. Please tell me where am I making a mistake.
n = input ('Enter number of equations: ');
syms x y
for j=1:n
equ(j)= string(input ('Enter equations: ','s') );
end
for j=1:n
func(j) = evalin(symengine, equ(j));
end
for j=1:n
fplot(func(j));
end

Answers (1)

KSSV
KSSV on 18 Sep 2017
% plot tow straight lines
L1 = [0.4018 0.2399 ; 0.0760 0.1233 ] ;
L2 = [0.1839 0.4173; 0.2400 0.0497] ;
% plot
figure
hold on
plot(L1(1,:),L1(2,:),'r') ;
plot(L2(1,:),L2(2,:),'b') ;
% Intersection point
P = InterX(L1,L2) ;
plot(P(1),P(2),'*k')

Categories

Find more on Mathematics in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!