How can I use the solve command in Matlab to find the intersection of two equations?
조회 수: 11 (최근 30일)
이전 댓글 표시
eqn1 = x^2 + y^2 ==9;
eqn2 = 2*x + 3*y == 4;
S = solve(eqn2==eqn1)
댓글 수: 0
답변 (1개)
DGM
2021년 11월 27일
Something like this:
% solve system of equations
syms x y
eqn1 = x^2 + y^2 == 9;
eqn2 = 2*x + 3*y == 4;
S = solve([eqn2 eqn1],[x y]);
sx = double(S.x)
sy = double(S.y)
% just plot things numerically and see if the solutions make sense
N = 50;
x = linspace(-4,4,N);
y = x.';
surf(x,y,sqrt(x.^2+y.^2),'facealpha',0.8); hold on % a circle
surf(x,y,3*ones(N,N),'facealpha',0.8) % with radius 3
plot3(x,(4-2*x)/3,3*ones(1,N)) % intersects with a diagonal line
plot3(sx,sy,[3 3],'o','linewidth',2) % mark calculated solution points
colormap(parula)
shading flat
참고 항목
카테고리
Help Center 및 File Exchange에서 Calculus에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!