Function output is returning equation not value

Hi guys,
Im fairly new to MATLAB and im sure this is a quick fix...
I made a function to calculate the twist of a beam.
my last line of code is convertinf the answer in rad to degrees.
the fuction returns the devision the last line does not the value of the devision.
when I evaluate I get the correct answer. I want the function to just output the twist angle in deg.
Any ideas?
function P = twist(funky,A,B,G,Rinner,Router)
J = (pi/2)*(Router^4-Rinner^4); %calculate j in m^4
syms x;
t_x = int(funky,0,x);% intergrate internal tourqe function from 0 to x
pretty(t_x) %display intergration in nice format
T = int(t_x,A,B);%calculate intergral of t(x) dx and evaluate from A to B
rad = T/(G*J);% phi equation in rad
P = ((rad)*(180))/(pi);% convert red to deg
end

回答 (1 件)

Star Strider
Star Strider 2021 年 10 月 14 日

1 投票

If ‘rad’ is purely numeric (no symbolic variables), use the double function to onvert it to a double value.
Also consider using the rad2deg function, since it is a bit more robust than multiplying by .
.

2 件のコメント

Jamie Hobbs
Jamie Hobbs 2021 年 10 月 14 日
Thanks!
Star Strider
Star Strider 2021 年 10 月 14 日
My pleasure!
.

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

カテゴリ

ヘルプ センター および File ExchangeAerospace Blockset についてさらに検索

質問済み:

2021 年 10 月 14 日

コメント済み:

2021 年 10 月 14 日

Community Treasure Hunt

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

Start Hunting!

Translated by