N=length(A)
B=zeros(N,2)
for n=1:N
subA=A(max(1,n-5):min(N,n+5))
B(n,:)=[mean(subA),var(subA)]
end
B
第一题m=3
n=4
aaa=random('uniform',-1,1,m,n)
[nmax,~]=max(aaa(:))
[nmin,~]=min(aaa(:))
[irowmax,icolmax]=find(aaa>=max(aaa(:)))
[irowmin,icolmin]=find(aaa<=min(aaa(:)))
nmax
irowmax
icolmax
nmin
irowmin
icolmin
第二题不完整
第三题
f1=@(x)x.*cos(x)
f2=@(x)x.*cos(1./x)
x=linspace(0,2*pi)
y=f1(x)
figure(1)
plot(x,y,'-ko','linewidth',2)
xlabel('x')
ylabel('x*cos(x)')
figure(2)
plot(x,y,'-rs','linewidth',1)
xlabel('哗物蚂x')
ylabel('x*cos(x)')
x=linspace(0,2*pi)
y=f2(x)
figure(3)
plot(x,y,'-ko','linewidth',2)
xlabel('x')
ylabel('x*cos(x)'乱埋)
figure(4)
plot(x,y,'-rs'蚂模,'linewidth',1)
xlabel('x')
ylabel('x*cos(x)')
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)