How do I plot input equations from the user?

1 回表示 (過去 30 日間)
Swati Umamaheshwaran
Swati Umamaheshwaran 2017 年 9 月 18 日
回答済み: KSSV 2017 年 9 月 18 日
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

回答 (1 件)

KSSV
KSSV 2017 年 9 月 18 日
% 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')

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by