⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 plotfun.m

📁 数值方法和MATLAB实现与应用.zip
💻 M
字号:
function plotfun(ncycle,npts)
% plotfun   Plot sin(x), cos(x), and sin(x)*cos(x) for a prescribed
%           number of cycles and number of points per cycle
%
% Synopsis:  plotfun(ncycle,npts)
%
% Input:     ncycle = number of cycles (2*pi/cycle)
%            npts   = number of points to plot per cycle
%
% Output:    A plot in a separate figure window

x = linspace(0,ncycle*2*pi,ncycle*npts);    %  generate data
y1 = sin(x);
y2 = cos(x);
y3 = y1.*y2;             %  note the .* array operator

plot(x,y1,'-',x,y2,'.',x,y3,'--');
xlabel('x   (radians)')
legend('sin(x)','cos(x)','sin(x)*cos(x)')
title('Plot of simple trigonometric functions')

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -