필터 지우기
필터 지우기

how to substitute symbolic equation into symbolic equation, and to reorganize symbolic equations

조회 수: 2 (최근 30일)
I am trying to learn symbolic equations, but I'm worried they don't work the way I think they work, or are not intended for what I am hoping ot use them for.
My expectation is that I can solve problems by substituting relationships into larger constituent equations and reduce them analytically, then isolate the variable of interest, substitute values and solve for instance:
syms epsilon_33 delta_0 d_33 s_33 f f_bl u k_s k_l n V A L_s t
% known constants
d_33 = 3400e-12;
s_33 = 169e-12;
f = 60;
u = 30e-6;
V = 300;
% Relevent relationships
k_l/k_s == 1
u == delta_0/(1+k_1/k_2)
delta_0 == n*d_33*V
% For this simple example, the first two relationships say that delta_0=2*u, so the third relationship can be solved for n
I can make Matlab spit out the answer but I have to do the analytical solution myself, which kind of defeats the purpose.
Is what I am trying to do outside the scope of this function?

답변 (3개)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2022년 1월 31일
There are a couple of points in the code to be corrected and then you can get an analytical solution expressed in terms of other symbolic variables, e.g.:
syms epsilon_33 delta_0 d_33 s_33 f f_bl u k_s k_l n V A L_s t
% known constants
d_33 = 3400e-12;
s_33 = 169e-12;
f = 60;
u = 30e-6;
V = 300;
% Relevent relationships
% delta_0=u/(1+k_1/k_2);
% delta_0 == n*d_33*V;
% Presumably k_2 is also symbolic variable, and thus,
syms k_2
k_1 = 1/k_s;
Solution_n = solve(u/(1+k_1/k_2)-n*d_33*V==0, n)
Solution_n = 
  댓글 수: 1
cdlapoin
cdlapoin 2022년 1월 31일
so you have to combine the symbolic equations yourself? That is essentially what I was asking if you can avoid.

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


Paul
Paul 2022년 1월 31일
syms epsilon_33 delta_0 d_33 s_33 f f_bl u k_s k_l n V A L_s t
% known constants
d_33 = 3400e-12;
s_33 = 169e-12;
f = 60;
u = 30e-6;
V = 300;
% Relevent relationships
eq1 = k_l/k_s == 1
eq1 = 
%u == delta_0/(1+k_1/k_2) % this line appeared to contain two typos
eq2 = u == delta_0/(1+k_l/k_s)
eq2 = 
eq3 = delta_0 == n*d_33*V
eq3 = 
Now we can use solve(). Solving for three variables returns the expected result for n
sol = solve([eq1 eq2 eq3],[n delta_0 k_l])
sol = struct with fields:
n: 18889465931478580854784/321120920835135859375 delta_0: 3/50000 k_l: k_s
For reasons I don't understand, just asking to solve for n alone doesn't work, even though there is a clear solution
sol = solve([eq1 eq2 eq3],n)
sol = Empty sym: 0-by-1
  댓글 수: 1
Walter Roberson
Walter Roberson 2022년 2월 3일
Except in some cases involving inequalities, you must solve() for the same number of variables as you have equations

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


burak enes kavas
burak enes kavas 2022년 2월 3일
편집: Walter Roberson 2022년 2월 3일
% Do you want analyticaly reduce any function use this comand
syms x
func = sin ( x )
diff ( func , x)
ans = cos( x )
% Make analytical solution
solve ( cos ( x ) )
ans = pi/2 % variable type is sybolic
% change the varible type
double(ans) % variable type is integer
ans = 1.5708
more exaple
syms x
F = x^2 - 4
solve ( F , x )
ans = [ 2 , -2 ]
G= 3*x^2 - 3*x + 3
diff ( G ,x )
ans = 6*x - 3
i wish it is helpfull

카테고리

Help CenterFile Exchange에서 Conversion Between Symbolic and Numeric에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by