Error: Invalid expression log equation
6 ビュー (過去 30 日間)
古いコメントを表示
I am trying to solve an equation in Matlab mobile.
Following is the code -
syms t a
eqns =-a*log((3*t/4)*(3-t^2)/(2-t))-(1-a)*log((1/t^2)*((3-2*t)/(2-t)))+a*((1-t)^2)*(3-t)/((2-t)*(3-t^2)-(1-a)*(1+t)/(3-2*t))*((t*(-18+21*t-7*t^3+2*t^4)*(log((3-2*t)*(3-t^2)/(2*t(2-t)^2))))/(36-39*t+13*t^3-4*t^4+a*(-18+27*t-18*t^2+5*t^3)))+2*log((1/3)*(3-t^2)/(2-t))+t*log((4*(t^3)/27)*((3-t^2)/(3-2*t)))-2*t==0;
But I keep getting the error
Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.
0 件のコメント
採用された回答
Walter Roberson
2021 年 4 月 17 日
syms t a
eqns =-a*log((3*t/4)*(3-t^2)/(2-t))-(1-a)*log((1/t^2)*((3-2*t)/(2-t)))+a*((1-t)^2)*(3-t)/((2-t)*(3-t^2)-(1-a)*(1+t)/(3-2*t))*((t*(-18+21*t-7*t^3+2*t^4)*(log((3-2*t)*(3-t^2)/(2*t(2-t)^2))))/(36-39*t+13*t^3-4*t^4+a*(-18+27*t-18*t^2+5*t^3)))+2*log((1/3)*(3-t^2)/(2-t))+t*log((4*(t^3)/27)*((3-t^2)/(3-2*t)))-2*t==0;
% 12 1 2 1 2 10 1 0 12 1 23 2 3 210 12 1 0 1 0 12 1 2 1 2 1 2 1 2 10 12 3 2 3 45 4 5 4 5 6 5 4321 2 3 210 12 1 2 1 2 10 12 3 2 1 23 2 3 210
The bracket count is okay, it all balances out, and the error message you indicate does not occur. A different error occurs instead.
Have a look at the place the bracket count reaches 6:
% (2*t(2-t)^2)
% 5 6 5 4
Notice that you are trying to index t by 2-t . That is an error. You probably want (2*t*(2-t)^2)
15 件のコメント
Tomas
2023 年 5 月 2 日
the U in this case is a random variable. So, should I just change it to a different random variable to clear that issue?
Walter Roberson
2023 年 5 月 2 日
f_inv = @(x) log(-2*(2-x))
This will be complex-valued unless x >= 2.
It is not at all clear why you do not instead write
f_inv = @(x) log(2*(x-2))
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Equation Solving についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!