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?
0 个评论
回答(3 个)
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)
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
%u == delta_0/(1+k_1/k_2) % this line appeared to contain two typos
eq2 = u == delta_0/(1+k_l/k_s)
eq3 = delta_0 == n*d_33*V
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])
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)
1 个评论
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
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
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!