How do I plot input equations from the user?

16 vues (au cours des 30 derniers jours)
Swati Umamaheshwaran
Swati Umamaheshwaran le 18 Sep 2017
Réponse apportée : KSSV le 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

Réponses (1)

KSSV
KSSV le 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')

Catégories

En savoir plus sur Mathematics dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by