Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Symbolic calculation and to solve out a variable

1 回表示 (過去 30 日間)
Pouyan Msgn
Pouyan Msgn 2020 年 3 月 11 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
I have the equation :
I_1=2.15 ; I_2=8.625;
n2=0.039; n1=0.1;
L_1=16.76*10^-10
L_2=15.56*10^-10;
I tried with this code but it is wrong:
clc
clear all
syms I1 I2 n1 n2 L1 L2 d
I_1=2.15 ; I_2=8.625;
n2=0.039; n1=0.1;
L_1=16.76*10^-10
L_2=15.56*10^-10;
I1/I2=((n1*L1)/(n2*L2))*(1-exp(-d/L1))/(exp(-d/L2));
I want to solve d

回答 (2 件)

Steven Lord
Steven Lord 2020 年 3 月 11 日
Write your last line as an equation and use solve.
  1 件のコメント
Walter Roberson
Walter Roberson 2020 年 3 月 11 日
vpasolve(I_1/I_2==((n1*L_1)/(n2*L_2))*(1-exp(-d/L_1))/(exp(-d/L_2)), d)

Ameer Hamza
Ameer Hamza 2020 年 3 月 11 日
編集済み: Ameer Hamza 2020 年 3 月 11 日
First, your syntax is incorrect, as pointed out in Steven's answer. However, if you correct the syntax, the solve will still not be able to provide the solution because an analytical solution does not exist for such equations.
Your other choice is to use a numerical solver, such as fsolve. However, because of the scale of L_1 and L_2, and their presence in the exponent, directly using fsolve will get you nowhere. Therefore, you first need to scale the exponent and then apply fsolve. See the code
I_1=2.15 ; I_2=8.625;
n2=0.039; n1=0.1;
L_1=16.76*10^-10;
L_2=15.56*10^-10;
f = @(d) I_2/I_1*((n1*L_1)/(n2*L_2))*(1-exp(-d/L_1*10^-10))/(exp(-d/L_2*10^-10)) - 1;
d = fsolve(f, 1)*10^-10;
Here, I first scaled the exponents by a factor of 10^-10 and corrected the final solution by scaling again.

この質問は閉じられています。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by