Matlab代写八大最常用函数调用实例,快学起来!

 

针对早已触碰过matlab数控编程软件的留学人员们而言,它可以协助大家完成在优化算法开发设计、数据统计分析及其互动自然环境等各个方面的实际效果,在matlab之中大家可以将不一样的句子启用到一起来实行,这也是大家常说的涵数,那麼在具体的实际操作之中,大家应对着较多不一样的自变量必须选用的不一样的优化算法,我们要如何去自定义函数启用呢?文中致诚及哈啊与文化教育就依据互联网材料为诸位带了一些较为普遍的八个调用函数案例分析,不容易的学生们赶快学起來哦。

Matlab代写常见8个函数调用实例

1.三角波发生器

t=-3:0.01:3;

f1=tripuls(t);

subplot(3,1,1);

plot(t,f1);

axis([-3,3,-0.2,1.2])

set(gcf,'color','w');

f2=tripuls(t,4);

subplot(3,1,2);

plot(t,f2);

axis([-3,3,-0.2,1.2])

%set(gcf,'color','w');

f3=tripuls(t,4,-1);

subplot(3,1,3);

plot(t,f3);

axis([-3,3,-0.2,1.2])

2.离散变量编码序列的求和与乘积

function[x,n]=jxl(x1,x2,n1,n2)

n=min(min(n1),min(n2)):max(max(n1),max(n2));

s1=zeros(1,length(n));s2=s1;

s1(find((n>=min(n1))&(n<=max(n1))==1))=x1;

s2(find((n>=min(n2))&(n<=max(n2))==1))=x2;

x=s1 s2;//x=s1.*s2:%编码序列乘

axis([(min(min(n1),min(n2))-1),(max(max(n1),max(n2)) 1),(min(x)-0.5),(max(x) 0.5)])

 3.编码序列的反摺

function[x,n]=xlfz(x1,n1)

x=fliplr(x1);n=fliplr(n1);

stem(n,x,'filled')

axis([min(n)-1,max(n) 1,min(x)-0.5,max(x) 0.5])

4.编码序列的卷积和

function[x,n]=gghconv(x1,x2,n1,n2)

x=conv(x1,x2)

ns=n1(1) n2(1);

leg=length(x1) length(x2)-2;

n=ns:(ns leg)

subplot(2,2,1)

stem(n1,x1,'filled')

title('x1(n)')

xlabel('n')

subplot(2,2,2)

stem(n2,x2,'filled')

title('x2(n)')

xlabel('n')

subplot(2,2,3)

stem(n,x,'filled')

title('x(n)=n1(n) x2(n)')

xlabel('n')

p=get(gca,'position');

p(3)=2.4*p(3);

set(gca,'position',p)

5.l连续函数的卷积和

function[f,t]=gggfconv(f1,f2,t1,t2)

d=input('??ê?è?2é?ù????d:');

f=conv(f1,f2)

f=f*d;

ts=t1(1) t2(1);

l=length(f1) length(f2)-2;

t=ts:d:(ts l*d);

subplot(2,2,1)

plot(t1,f1)

axis([min(t1),max(t1),min(f1)-min(f1)*0.2,max(f1) max(f1)*0.2])

title('f1(t)')

xlabel('t')

subplot(2,2,2)

plot(t2,f2)

axis([min(t2),max(t2),min(f2)-min(f2)*0.2,max(f2) max(f2)*0.2])

title('f2(t)')

xlabel('t')

subplot(2,2,3)

plot(t,f)

axis([min(t),max(t),min(f)-min(f)*0.2,max(f) max(f)*0.2])

p=get(gca,'position');

p(3)=2.4*p(3);

set(gca,'position',p)

title('f(t)=f1(t)*f2(t)')

xlabel('t')

matlab代笔普遍的调用函数案例:6.周期时间数据信号傅里叶级数

display('傅里叶展开的项数')

m=input('m=');

t=-2*pi:0.01:2*pi;

n=round(length(t)/4);

f=[ones(n,1);-1*ones(n,1);ones(n,1);-1*ones(n 1,1)];

ones(314,1);

y=zeros(m 1,max(size(t)));

figure(1);

y(m 1,:)=f';

figure(1);

plot(t/pi,y(m 1,:));

grid;

axis([-2 2 -1.5 1.5]);

title('周期时间波形');

xlabel(size(t));

xlabel('企业:pi','Fontsize',8);

x=zeros(size(t));

kk='1'

for k =1:2:2*m-1

pause;

x=x sin(k*t)/k;

y((k 1)/2,:)=4/pi*x;

plot(t/pi,y(m 1,:));

hold on;

plot(t/pi,y((k 1)/2,:));

hold off;

grid;

axis([-2 2 -1.5 1.5]);

title(strcat('第',kk,'次谐波电流累加'));

xlabel('企业:pi','Fontsize',8);

kk=strcat(kk,',',num2str(k 2));

end

pause;

plot(t/pi,y(1:m 1,:));

grid;

axis([-2 2 -1.5 1.5]);

title('各次谐波电流累加');

xlabel('企业:pi','Fontsize',8);

7.cos(2/3pi*t)的取样

display('奈奎斯特周期时间1.5s,Ts<1.5,过采样,Ts>1.5,欠取样');

display('Please input the value of sample period');

Ts=input('Ts=');

t=0:0.01:40;

y=cos(2/3*pi*t);

subplot(221);

plot(t,y);

axis([0 6 -1.1 1.1]);

xlabel('t  企业:s','Fontsize',8');

title('f(t)');

line([0 6],[0 0],'color',[0 0 0]);

N=300;

k=-N:N;

W=2*pi*5;

w=k*W/N;

Y=0.01*y*exp(-j*t'*w);

Y=abs(Y);

subplot(222);

plot(w/pi,Y);

axis([-2,2,0,pi*7 0.2])

xlabel(' \omega 企业:s');

title('F(j\omega)');

subplot(223);

plot(t,y,'b:');

hold on

t2=0:Ts:40;

y2=cos(2/3*pi*t2)

stem(t2,y2);

axis([0 6 -1.1 1.1]);

xlabel('t  企业:s','Fontsize',8');

title('fs(s)');

hold off

Y2=Ts*y2*exp(-j*t2'*w);

Y2=abs(Y2);

subplot(224);

plot(w/pi,Y,'b')

xlabel(' \omega 企业:s');

title('Fs(omega)');

hold on

plot(w/pi,Y2,'r');

axis([-2,2,0,pi*10]);

hold off

8.Sa的取样与重新构建

%奈奎斯特k=1,01,欠取样

display('Please input the value of k');

k=input('k=');

wm=1;         %信号带宽

Ts=k*pi/wm; %取样间距

ws=2*pi/Ts; %取样角频率

wc=ws/2;  %    过滤器截止频率

n=-10:10;    %取样点的总数

m=fix(length(n)/2);       %单侧取样周期时间  fix为求整

nTs=n*Ts;           %测算每一个取样点

dt=0.05;

t=-m*Ts:dt:m*Ts;

f=sinc(nTs/pi);

fa=f*Ts*wc/pi*sinc((wc/pi)*(ones(length(nTs),1)*t-nTs'*ones(1,length(t))));

f2=sinc(t/pi);

subplot(311);

stem(nTs,f);     %绘图取样数据信号

hold on

plot(t,f2,'r:');         %绘图线性

xlabel('t ');

title('对Sa(t)数据信号开展取样');

axis([-m*Ts m*Ts -0.5 1.2]);

hold off

subplot(312);

h1=plot(t,fa);    %绘图重新构建数据信号

hold on

for i = -m*Ts:dt:m*Ts

ft=sinc(i/pi)*sinc(wc/pi*(t-i));       %绘图重新构建数据信号的每个排风量

h2=plot(t,ft,'m:');

hold on

yy=sinc(i/pi);

yy1=yy*yy;

plot(i,yy1,'o');

endxlabel('t ');

title('重新构建数据信号');

axis([-m*Ts m*Ts -0.5 1.2]);

legend([h1,h2],'重新构建数据信号','分数据信号')

hold off

subplot(313);

error=abs(fa-f2);

plot(t,error);

axis([-m*Ts m*Ts min(error) max(error) 0.1*max(error)]);

xlabel('t');

ylabel(' error(t)');

大家必须依据具体的状况来挑选应用不一样的调用函数,让matlab可以更强的完成大家所必须的实际效果,在matlab之中涵数的实行是可以同時间解决和回到好几个輸出主要参数,这一点诸位留学人员们必须好好地去了解。必须matlab代笔的学生们赶快在线留言网址网上客服吧~

发表回复

客服一号:点击这里给我发消息
客服二号:点击这里给我发消息
微信客服1:essay-kathrine
微信客服2:essay-gloria