多语言展示
当前在线:139今日阅读:19今日分享:20

MATLAB演示6种常见的三角函数

sin( ),cos( ),tan( ),cot( ),sec( ),csc( )是MATLAB提供的6种常见三角函数(命令),分别为:(1)正弦:sin( ),对边比斜边。(2)余弦:cos( ),邻边比斜边。(3)正切:tan( ),对边比领边。(4)余切:cot( ),邻边比对边。(5)正割:sec( ),斜边比邻边,即余弦的倒数。(6)余割:csc( ),斜边比比对边,即正弦的倒数。
工具/原料
1

MATLAB

2

三角函数

方法/步骤
1

第一,输入以下代码,分别演示正弦sin( ),余弦cos( ),正切tan( ),余切cot( ),正割sec( ),余割csc( )六种常见的三角函数,其中定义域为0到4pi(未考虑pi/2,pi等时正切余切无意义即分母为0等情况)。close all; clear all; clct = 0:pi/30:4*pi;y_sin = sin(t); % 正弦函数y_cos = cos(t); % 余弦函数y_tan = tan(t); % 正切函数y_cot = cot(t); % 余切函数y_sec = sec(t); % 正割函数y_csc = csc(t); % 余割函数figure(1);plot(t,y_sin,'r-','LineWidth',3);figure(2);plot(t,y_cos,'g-','LineWidth',3);figure(3);plot(t,y_tan,'y-','LineWidth',3);figure(4);plot(t,y_cot,'b-','LineWidth',3);figure(5);plot(t,y_sec,'k-','LineWidth',3);figure(6);plot(t,y_csc,'c-','LineWidth',3);figure(7);plot(t,y_sin,'r-','LineWidth',3);hold onplot(t,y_cos,'g-','LineWidth',3);plot(t,y_tan,'y-','LineWidth',3);plot(t,y_cot,'b-','LineWidth',3);plot(t,y_sec,'k-','LineWidth',3);plot(t,y_csc,'c-','LineWidth',3);hold offlegend('sin','cos','tan','cot','sec','csc')xlabel('t');ylabel('y');

2

第二,保存和运行上述代码,得到正弦sin( )函数图像如下。

3

第三,得到余弦cos( )函数图像如下。

4

第四,得到正切tan( )函数图像如下。

5

第五,得到余切cot( )函数图像如下。

6

第六,得到正割sec( )函数图像如下。

8

最后,把正弦sin( ),余弦cos( ),正切tan( ),余切cot( ),正割sec( ),余割csc( )六种常见的三角函数绘制在一张图上,如下。

推荐信息