필터 지우기
필터 지우기

Solve numerical equation with Y at both sides

조회 수: 6 (최근 30일)
Ron Nativ
Ron Nativ 2020년 8월 23일
댓글: Star Strider 2020년 8월 24일
Hi all,
I have a general equation I would like to solve. However, it contains the dependent variable Y on both sides.
The eqaution is: Y/Y_0 = B * (1 + x*Y/D)^0.5 * (1-x)^alpha
Where x is the independent variable,
and Y_0, B, D and alpha are constants. What would be the most appropriate function in Matlab for this particular problem?
Thanks,
Ron

답변 (3개)

KSSV
KSSV 2020년 8월 23일
You can use symbolic package. Something like this:
syms Y_0 Y B x Y D alpha
eqn = Y/Y_0 - B * (1 + x*Y/D)^0.5 * (1-x)^alpha==0 ;
s = solve(eqn,Y)
  댓글 수: 1
Ron Nativ
Ron Nativ 2020년 8월 24일
Thank you KSSV. Is there a big difference between this and using vpasolve?

댓글을 달려면 로그인하십시오.


Star Strider
Star Strider 2020년 8월 23일
A numeric approach:
Y_0 = 3; % Define Constants
B = 5;
D = 7;
alpha = 11;
x = linspace(0, 0.9, 10);
Yfcn = @(Y,x) B * sqrt(1 + x*Y/D) .* (1-x).^alpha - Y/Y_0; % Use Element-Wise Operations
for k = 1:numel(x)
Y(k) = fzero(@(Y)Yfcn(Y,x(k)), 0.1);
end
figure
plot(x, Y)
grid
Note that if ‘x>1’ the result will be complex (regardless of what the other constants are), and the fzero function will fail. Consider using fsolve instead in this event.
  댓글 수: 2
Ron Nativ
Ron Nativ 2020년 8월 24일
Thanks Star Strider. Luckiliy, my x values are always between 0 and 1.
Star Strider
Star Strider 2020년 8월 24일
Then this should work!

댓글을 달려면 로그인하십시오.


Alan Stevens
Alan Stevens 2020년 8월 23일
편집: Alan Stevens 2020년 8월 23일
Your equation can also be expressed as a quadratic in Y
which could be solved using roots (for specified values of x).
You would need to check that the solutions were consistent with the original equation.

카테고리

Help CenterFile Exchange에서 Calculus에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by