How to use Greek Letters in equation

183 ビュー (過去 30 日間)
Aloe
Aloe 2022 年 7 月 26 日
回答済み: Stephen23 2022 年 7 月 26 日
Hello
I am still new to MatLAB but below is my attempt on using greek letters in my equation. It comes up with an error saying "Invalid use of operator" and some other errors in connector which is confusing for me. Been trying to fix it but no hope.
Any help will be appreciated.
k1 = \omega .* sqrt((\mu .* \epsilon)/(2)) .* sqrt((1 + ((\sigma)/(\epsilon .* \omega))^2) + 1);
Invalid use of operator.

Error in connector.internal.fevalMatlab

Error in connector.internal.fevalJSON
k2 = \omega .* sqrt((\mu .* \epsilon)/(2)) .* sqrt((1 + ((\sigma)/(\epsilon .* \omega))^2) - 1);
k = k1 + i.*k2;
disp(k)
  6 件のコメント
KSSV
KSSV 2022 年 7 月 26 日
Why you want special symbols in equation? They are variables.
Aloe
Aloe 2022 年 7 月 26 日
@KSSV My equation has them as constants so I thought I could use them as constants like that

サインインしてコメントする。

採用された回答

Aloe
Aloe 2022 年 7 月 26 日
編集済み: Aloe 2022 年 7 月 26 日
I improved it and hope this makes it more right to be considered a code in MatLAB
omega = evalin(symengine, '`ω`');
mu = evalin(symengine, '`µ`');
epsilon = evalin(symengine, '`ϵ`');
sigma = evalin(symengine, '`σ`');
k1 = omega * sqrt((mu .* epsilon)/(2)) * sqrt((1 + ((sigma)/(epsilon * omega))^2)+1);
k2 = omega * sqrt((mu * epsilon)/(2)) * sqrt((1 + ((sigma)/(epsilon * omega))^2)-1);
k = k1 + 1i*k2;
disp(k)

その他の回答 (1 件)

Stephen23
Stephen23 2022 年 7 月 26 日
The MATLAB approach:
syms omega mu epsilon sigma
k1 = omega .* sqrt((mu .* epsilon)/(2)) .* sqrt((1 + ((sigma)/(epsilon .* omega))^2) + 1);
k2 = omega .* sqrt((mu .* epsilon)/(2)) .* sqrt((1 + ((sigma)/(epsilon .* omega))^2) - 1);
k = k1 + i.*k2
k = 

Community Treasure Hunt

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

Start Hunting!

Translated by