0
matlab에서 선형 방정식 시스템을 풀려고합니다. 방정식의 계수는 런타임에 사용자가 제공해야합니다. 문제는 솔루션이 기호 변수로 matlab에 의해 주어졌으며 이중처럼 사람이 읽을 수있는 형식으로 변환 할 수 없다는 것입니다. 내 스크립트 :런타임에 제공된 계수를 사용하여 matlab에 선형 방정식 시스템을 해결
% Accept coefficient of x in eqn one
a11 =input('Enter coefficient of x eqn one:');
%Accept coeff of y in eqn one
a12 = input('Enter coefficient of y in eqn one: ');
%Accept the constant term of eqn one
c1 = input('Enter the constant term in eqn one:');
%Form eqn one
eqn1 =sym('a11*x + a12*y + c1');
eqn_one = subs(eqn1, {a11, a12, c1},{a11, a12, c1})
a21 = input('Enter coefficient of x in eqn two:');
a22 = input('Enter coefficient of y in eqn two:');
c2 = input('Enter the constant term in eqn two:');
eqn2 = sym('a21*x + a22*y + c2');
eqn_two = subs(eqn2, {a21, a22, c2},{a21, a22, c2})
solve(eqn_one, eqn_two)
이 MATLAB의 결과입니다
ANS = 당신은 결과를 저장해야
x: [1x1 sym]
y: [1x1 sym]
아마도'solve (eqn_one == eqn_two)'또는'S = solve (eqn_one, eqn_two); S.x; S.y;'? 그런데 왜 sym를 사용하고 싶습니까? –
선형 방정식을 풀 때 심볼릭 도구 상자가 필요하지 않습니다. – knedlsepp