I wanna solve to solve

10 ビュー (過去 30 日間)
Yunho Choi
Yunho Choi 2011 年 8 月 23 日
回答済み: Walter Roberson 2024 年 11 月 6 日 6:20
my solve equation like this....
[R2,x]=solve('((1-R2)/(1-R1)*-(b/c*R2))*x^2+(1-R2)/(1-R1)-b/c=0','((2-R1-R2)/(1-R1))*a*x^2+(b+c)*(1-R2)*x+a*(((1-R2)/(1-R1)+R1)+R2)=0','R2,x');
it is very complex i think.
so replace number(by input) from coefficient(R1,a,b,c) before!! executing solve equation.(Don't say that first solve second subs)
To my purpose, chane my code
a=input('a:');
b=input('b:');
c=input('c:');
R1=input('R1');
fn1=((1-R2)/(1-R1)*R1-(b/c*R2))*x^2+(1-R2)/(1-R1)-b/c;
fn2=((2-R1-R2)/(1-R1))*a*x^2+(b+c)*(1-R2)*x+a*(((1-R2)/(1-R1)+R1)+R2);
[R2,x]=solve('fn1=0','fn2=0','R2,x')
but it doesn't work!! help me!!!

回答 (2 件)

Ayush
Ayush 2024 年 11 月 6 日 5:07
To solve your equations with numerical coefficients in MATLAB, you need to substitute the values into the equations before using the solve function.
This is how you can do it:
% substitute the values
a = input('a: ');
b = input('b: ');
c = input('c: ');
R1 = input('R1: ');
% Define symbolic variables
syms R2 x;
% Define the equations with substituted numerical values
fn1 = ((1-R2)/(1-R1)*R1 - (b/c)*R2)*x^2 + (1-R2)/(1-R1) - b/c;
fn2 = ((2-R1-R2)/(1-R1))*a*x^2 + (b+c)*(1-R2)*x + a*(((1-R2)/(1-R1) + R1) + R2);
% Solve
solutions = solve(fn1 == 0, fn2 == 0, R2, x);

Walter Roberson
Walter Roberson 2024 年 11 月 6 日 6:20
The fundamental problem here is that when you use the old form of solve that used quoted expressions, that variables defined in previous expressions do not have their values substituted when evaluating quoted expressions.
To use quoted expressions, you would have had to use
eqn1 = subs('fn1=0');
eqn2 = subs('fn2=0');
[R2,x] = solve(eqn1, eqn2,'R2', 'x')

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by