سؤال

if I write in matlab

cos(pi/4)

I get this form:

0.7071

when I'd prefer getting it actual value of (2)^(1/2)/2 to write formulas more clearly. is there a way to do what I ask?

هل كانت مفيدة؟

المحلول

You can you use the Symbolic Math toolbox that comes with many installs of Matlab:

theta = sym(pi)/4;
cos(theta)

which returns

ans =

2^(1/2)/2
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top