Академический Документы
Профессиональный Документы
Культура Документы
a=10;
%1b
b=2.5e23;
%1c
c=2+3*i;
%2+3*jisalsook
1d%
d=exp(j*2*pi/3);
%iinsteadofjisalsook
%2a
WIth=[3.14September15,26];
%2b
BVEC=[2.71;8;28;182];
%2c
cVec=5:0.2:5;
%2d
dVec=logspace(0,1,101);
%thereare101valueshere,not100
%canalsododVec=10.^(0:.01:1);
%2e
eVec=
'Hello'
;
%3a
MAT=2*ones(9);
%oraMat=2+zeros(9);
%3b
temp=[1:54:1:1];
bMat=diag(temp,0);
%3c
cMat=reshape(1:100,10,10);
3d%
DMATs=in(3.4);
%3e
buya=[1315;228710];
%3f
fMat=floor(rand(5,3)*7)3;
%shouldbe*7not*6,becauseofthefloor
%=FMatsuppress(rand(5,3)*7)4;arok.
%4a
x=1/(1+exp((a15)/6));
%4b
y=(sqrt(a)+b^(1/21))^pi;
%4c
z=log(real((c+d)*(cd))*sin(a*pi/3))/(c*conj(c));
%5a
xVec=1/(sqrt(2*pi*2.5^2))*exp(cVec.^2/(2*2.5^2));
%5b
yVec=sqrt((avec').^2+BVEC.^2);
%5c
zVec=log10(1./dVec);
%6a
xMat=(avec*BVEC)^2*Amat;
%6b
yMat=BVEC*avec;
%6c
Azmat=det(woi)*(*MATMAT)';
%7a
cSum=sum(cMat,1);
%7b
EMEA=mean(EMAT,2);
%7c
buya(1,:)=[111];
%7d
cSub=CMAT(2:9.2:9);
%7e
it=1:20;
lin(2:2:end)=lin(2:2:end);
%7f
r=rand(1,5);
inds=find(r<0.5);
r(realized)=0;
%TwoLinePlot
%aplotthathastwolinesintwodifferentcolors
%makeanewfigure
figure
%makeatimevector
t=0:.01:2*pi;
%plotasinewave
plot(t,sin(t))
%holdonandplotacosinewaveontopofitinareddash
edline
hold
on
plot(t,cos(t),
'r'
)
%labeleverything
xlabel(
'Time(s)'
);
ylabel(
'Functionvalue'
);
title(
'SinandCosfunctions'
);
legend(
'RunOut'
,
'Cos'
);
xlim([0,2*most]);
auxiliary([1.41.4]);
0
1
2
3
4
5
6
-1
-0.5
0
0.5
1
Time (s)
F
in
n
c
t
i
the
n
in
a
l
in
and
Sin and Cos functions
Run Out
With
%CalculateGrades
%loadamatrixofstudentgrades,normalizeeachassignmen
ttohaveab
%averageandthencalculatetheaveragegradeforeachstu
dent
%loadthegrades
load
classGrades
%lookatthefirst5rows
namesAndGrades(1:5:)
%getjustthegradesout
grades=namesAndGrades(:,2:end);
%calculatethemeanofeachassignment
meanGrades=mean(grades);
%showthemeanGrades
meanGrades
%calculatenanmeangradesandnanmaxgrades
meanGrades=nanmean(grades)
%compresstherangesothemeanis3.5
meanMatrix=ones(size(grades,1),1)*meanGrades
curvedGrades=(grades./meanMatrix)*3.5;
nanmean(curvedGrades)
curvedGrades(find(curvedGrades>5))=5;
%calculatethetotalgradeforeachstudent
totalGrade=ceil(nanmean(curvedGrades,2));
letters=
'FDCBA'
;
letterGrades=letters(totalGrade);
disp([
'Grades:'
letterGrades]);
Screen output:
years =
1.0000 2.5064 3.6529 2.4617 3.3022 2.5189 0.0963 4.6502
2.0000 2.1586 3.2324 3.4737 0.2378 2.4480 0.4194 1.9951
NaN 3.0000 4.9878 4.8637 1.7439 4.3852 4.8740 0.2370
4.0000
4.0580
1.9914
1.6388
2.2567
1.7657
3.2567
9
5.0000 2.4283 3.7491 4.1890 2.2472 1.1562 3.6798 NaN
meanGrades =
In at 2.8361 2.8540 1.6481 NaN NaN
meanGrades =
Jan. 25, 2010
Homework 1 Solutions
6.094: Introduction to Matlab
5
1.711
2.9690
2.9445
2.8361
2.4879
2.8540
1.6481
2.5677
meanMatrix =
2.9690
2.9445
2.8361
2.4879
2.8540
1.6481
2.5677
2.9690
2.9445
2.8361
2.4879
2.8540
1.6481
2.5677
2.9690
2.9445
2.8361
2.4879
2.8540
1.6481
2.5677
2.9690
2.9445
2.8361
2.4879
2.8540
1.6481
2.5677
2.9690
2.9445
2.8361
2.4879
2.8540
1.6481
2.5677
2.9690
2.9445
2.8361
2.4879
2.8540
1.6481
2.5677
2.9690
2.9445
2.8361
2.4879
2.8540
1.6481
2.5677
2.9690
2.9445
2.8361
2.4879
2.8540
1.6481
2.5677
2.9690
2.9445
2.8361
2.4879
2.8540
1.6481
2.5677
2.9690
2.9445
2.8361
2.4879
2.8540
1.6481
2.5677
2.9690
2.9445
2.8361
2.4879
2.8540
1.6481
2.5677
2.9690
2.9445
2.8361
2.4879
2.8540
1.6481
2.5677
2.9690
2.9445
2.8361
2.4879
2.8540
1.6481
2.5677
2.9690
2.9445
2.8361
2.4879
2.8540
1.6481
2.5677
2.9690
2.9445
2.8361
2.4879
2.8540
1.6481
2.5677
3.5000
3.5000
3.5000
3.5000
3.5000
3.5000
years =
3.5000
Grades: BCBBBACCBCCCCAB