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

📄 sinecomp.m

📁 matlab code for new user to design any project
💻 M
字号:
function sinecomp(n)
%sinecomp(n) where n is the number of terms used in 'mysine'
%this m-file tests the difference between the function [x]=mysine(theta,n)
%and the built-in MATLAB function [x]=sin(theta)
t=0:pi/100:2*pi;
s=sin(t);
i=0;
for t1=0:pi/100:2*pi;
   i=i+1;
   ms(i)=mysine(t1,n);
end;
plot(t,s,'b')
%axis tight
hold on
plot(t,ms,'g')
plot(t,(ms-s),'r')
xlabel('Theta, /(radians)')
legend('MATLAB Sin','Mysine','Error')
x=[0 2*pi];y=[0 0];plot(x,y,'k')
title(['Mysine error check: ' int2str(n) ' terms'])
text(.5,-.5,['max error=' num2str(max(abs((ms-s))))])
hold off

⌨️ 快捷键说明

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