Evaluating an expression in terms of x:

How do I evaluate these expressions in terms of x?
1.) tan(2x-45degrees) 2.) sin(30degrees-3x)
also, how do I put the symbol for degrees? sorry im just new in matlab, thank you very much.

Antworten (2)

Paulo Silva
Paulo Silva am 15 Aug. 2011

1 Stimme

%make them anonymous functions
f1=@(x)tand(2*x-45) %notice that's not tan but tand, it uses degrees
f2=@(x)sind(30-3*x) %instead of radians
%evaluate at specific x values
x=0;
f1(x)
f2(x)
%plot them easily
subplot(211) %create one axes to show the first function
ezplot(f1) %you can define the x range like this ezplot(f1,[0 100])
subplot(212) %create another axes to show the second function
ezplot(f2) %ezplot(f2,[0 100]) -> this makes x start at 0 and finish at 100

7 Kommentare

Fangjun Jiang
Fangjun Jiang am 15 Aug. 2011
Great! I learned sind() today!
Dwyane  Wade
Dwyane Wade am 15 Aug. 2011
yeah thank you for teaching me sind too! By the way, when I use sind and the expression is: sind(2*x-45), does 2 also become in degree form? will this make the expression 2degrees*x-45degrees? I'm confused...
Paulo Silva
Paulo Silva am 15 Aug. 2011
using sind all you put inside those () is in degree units, the word degrees means nothing to MATLAB.
Dwyane  Wade
Dwyane Wade am 15 Aug. 2011
oh, but the problem is: tan(2x-45degrees). only 45 is in degree mode 2x are as is. How do I solve that?
Paulo Silva
Paulo Silva am 15 Aug. 2011
tand(180*2*x/pi-45) or use Fangjun code
Paulo Silva
Paulo Silva am 15 Aug. 2011
Conversions
rad -> deg
180*x/pi
deg -> rad
pi*x/180
Fangjun Jiang
Fangjun Jiang am 15 Aug. 2011
You can't do degree*degree! Why not run an example?
x=90;
sind(x)
sind(2*x)

Melden Sie sich an, um zu kommentieren.

Fangjun Jiang
Fangjun Jiang am 15 Aug. 2011

0 Stimmen

x=pi;
y=tan(2*x-pi*45/180)
z=sin(pi*30/180-3*x)
All the functions tan(), sin(), cos() etc use radius, you need to convert degree to radius.

Kategorien

Mehr zu Aerospace Blockset finden Sie in Hilfe-Center und File Exchange

Tags

Gefragt:

am 15 Aug. 2011

Community Treasure Hunt

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

Start Hunting!

Translated by