Assignment4 key to Introduction to MATLAB(MIT OPEN COURSEWARE)
rd.m
Z=2+5*randn(500,1);
mean(Z)
std(Z)
handlesPractice.m
x=[0:2*pi/100:2*pi];
y=sin(x);
figure;
plot(x,y,'r');
xlim([0 2*pi]);
set(gca,'XTick',[0 pi 2*pi]);
set(gca,'XTickLabel',{'0','1','2'});
set(gca,'YTick',[-1:.5:1]);
grid on;
set(gca,'ycolor','g');
set(gca,'xcolor','c');
set(gcf,'color',[.3 .3 .3]);
title('One sine wave from 0 to 2');
histgr.m
count=1000;
A=poissrnd(2,1,count);
[N,X]=histc(A,[0:1:13]);
bar(N/count);
hold on;
plot([0:1:13],poisspdf([0:1:13],2));
coinTest.m
count=5000;
head=0;
P=rand(1,count);
CP=cumsum(P);
CP./=[1:1:count];
figure;
plot([1:1:count],CP,'k');
hold on;
plot([1:1:count],0.5*ones(count,1),'r');
ylim([0 1]);
cel.m
C=cell(3,3);
C(1,1)='Joe';
C(1,2)='Smith';
C(1,3)=30000;
C(2,1)='Sarah';
C(2,2)='Brown';
C(2,3)=150000;
C(3,1)='Pat';
C(3,2)='Jackson';
C(3,3)=120000;
a=dir;
for i=1:size(a,1)
if(!isdir(a(i).name))
fprintf('File %s contains %d bytes.\n',a(i).name,a(i).bytes);
end
end
补充:综合编程 , 其他综合 ,