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

Risposte (1)

Star Strider
Star Strider il 14 Ott 2021
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 .
.

Categorie

Scopri di più su Aerospace Blockset in Centro assistenza e File Exchange

Richiesto:

il 14 Ott 2021

Commentato:

il 14 Ott 2021

Community Treasure Hunt

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

Start Hunting!

Translated by