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

2025-10-23 17:40:08

1、第一,输入以下代码,分别演示正弦sin( ),余弦cos( ),正切tan( ),余切cot( ),正割sec( ),余割csc( )六种常见的三角函数,其中定义域为0到4pi(未考虑pi/2,pi等时正切余切无意义即分母为0等情况)。

close all; clear all; clc

t = 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 on

plot(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 off

legend('sin','cos','tan','cot','sec','csc')

xlabel('t');ylabel('y');

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

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

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

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

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

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

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

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

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

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

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

7、第七,得到余割csc( )函数图像如下。

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

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

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

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢