MATLAB的问题,那位大侠能帮个忙,后天就要交作业了,
来源:学生作业帮 编辑:大师作文网作业帮 分类:英语作业 时间:2024/09/21 14:42:34
MATLAB的问题,那位大侠能帮个忙,后天就要交作业了,
1.The Fibonacci numbers are computed according to the following relation:
with F0=F1=1.
(1) Write a function,F=fibo(n),to generate Fibonacci numbers in a vector F.Compute the first 10 Fibonacci numbers using the function;
(2) For the first 50 Fibonacci numbers,compute the ratio
It is claimed that this ratio approaches the value of the golden mean .What do your results show?
2.(Optional) Zeller's Congruence is a formula that calculates the day of the week given the date (within a limited range of years).The formula is:
day = 1 + ([2.6m - 0.2] + d + y + [y/4] + [c/4] - 2c) modulo 7
where the square brackets mean take the integer part,modulo 7 means the remainder when divided by 7,and
d = day of the month (e.g.1 to 31)
m = month number with March=1,...,December=10,January=11,
February=12.Assign January and February to previous year.
c = century number (e.g.19)
y = year in century (e.g.97),but remember January and February
The result is the day of the week,with 1=Sunday.Write a function dayofweek which takes a vector of three numbers representing the day,month and year in conventional notation,and returns a string containing the name of the day of the week.For example (attack on Pearl Harbour):
dayofweek([7 12 1941])
ans=
Sunday
(Hints:use Matlab function rem and fix)
1.The Fibonacci numbers are computed according to the following relation:
with F0=F1=1.
(1) Write a function,F=fibo(n),to generate Fibonacci numbers in a vector F.Compute the first 10 Fibonacci numbers using the function;
(2) For the first 50 Fibonacci numbers,compute the ratio
It is claimed that this ratio approaches the value of the golden mean .What do your results show?
2.(Optional) Zeller's Congruence is a formula that calculates the day of the week given the date (within a limited range of years).The formula is:
day = 1 + ([2.6m - 0.2] + d + y + [y/4] + [c/4] - 2c) modulo 7
where the square brackets mean take the integer part,modulo 7 means the remainder when divided by 7,and
d = day of the month (e.g.1 to 31)
m = month number with March=1,...,December=10,January=11,
February=12.Assign January and February to previous year.
c = century number (e.g.19)
y = year in century (e.g.97),but remember January and February
The result is the day of the week,with 1=Sunday.Write a function dayofweek which takes a vector of three numbers representing the day,month and year in conventional notation,and returns a string containing the name of the day of the week.For example (attack on Pearl Harbour):
dayofweek([7 12 1941])
ans=
Sunday
(Hints:use Matlab function rem and fix)
咋又来问了,我不是已经帮你做好了吗?
第1题 建立如下的m文件(知道怎么建m文件吗,file->new->m-file,然后把下面的东西敲进去,然后保存file->save,文件名就叫fibo.m)
function f=fibo(n)
if n==0
f=1;
else
if n==1
f=[1 1];
else
temp=fibo(n-1);
f=[temp,temp(end)+temp(end-1)];
end
end
下面是答案
第(1)小题
在命令行里敲
fibo(9)
屏幕就会显示
ans =
1 1 2 3 5 8 13 21 34 55
第(2)小题
在命令行里敲
a=fibo(50);
fibo(49)./a(2:end)
屏幕就会显示
ans =
Columns 1 through 9
1.0000 0.5000 0.6667 0.6000 0.6250 0.6154 0.6190 0.6176 0.6182
Columns 10 through 18
0.6180 0.6181 0.6180 0.6180 0.6180 0.6180 0.6180 0.6180 0.6180
Columns 19 through 27
0.6180 0.6180 0.6180 0.6180 0.6180 0.6180 0.6180 0.6180 0.6180
Columns 28 through 36
0.6180 0.6180 0.6180 0.6180 0.6180 0.6180 0.6180 0.6180 0.6180
Columns 37 through 45
0.6180 0.6180 0.6180 0.6180 0.6180 0.6180 0.6180 0.6180 0.6180
Columns 46 through 50
0.6180 0.6180 0.6180 0.6180 0.6180
下面你就在作业本上写
We can find the ratio approaches the value of the golden mean.
第2题
建立如下m文件
function day=dayofweek(x)
d=x(1);m=mod(x(2)-2,12);
yy=x(3);
if m>10
yy=yy-1;
end
y=rem(yy,100);
c=floor(yy/100);
switch mod(1+(floor(2.6*m -0.2)+d+y+floor(y/4)+floor(c/4)-2*c),7)
case 1
day='Sunday';
case 2
day='Monday';
case 3
day='Tuesday';
case 4
day='Wednesday';
case 5
day='Thursday';
case 6
day='Friday';
case 0
day='Saturday';
end
下面是例子
在命令行里面敲
dayofweek([8 6 2008])
屏幕就会显示
ans =
Sunday
第1题 建立如下的m文件(知道怎么建m文件吗,file->new->m-file,然后把下面的东西敲进去,然后保存file->save,文件名就叫fibo.m)
function f=fibo(n)
if n==0
f=1;
else
if n==1
f=[1 1];
else
temp=fibo(n-1);
f=[temp,temp(end)+temp(end-1)];
end
end
下面是答案
第(1)小题
在命令行里敲
fibo(9)
屏幕就会显示
ans =
1 1 2 3 5 8 13 21 34 55
第(2)小题
在命令行里敲
a=fibo(50);
fibo(49)./a(2:end)
屏幕就会显示
ans =
Columns 1 through 9
1.0000 0.5000 0.6667 0.6000 0.6250 0.6154 0.6190 0.6176 0.6182
Columns 10 through 18
0.6180 0.6181 0.6180 0.6180 0.6180 0.6180 0.6180 0.6180 0.6180
Columns 19 through 27
0.6180 0.6180 0.6180 0.6180 0.6180 0.6180 0.6180 0.6180 0.6180
Columns 28 through 36
0.6180 0.6180 0.6180 0.6180 0.6180 0.6180 0.6180 0.6180 0.6180
Columns 37 through 45
0.6180 0.6180 0.6180 0.6180 0.6180 0.6180 0.6180 0.6180 0.6180
Columns 46 through 50
0.6180 0.6180 0.6180 0.6180 0.6180
下面你就在作业本上写
We can find the ratio approaches the value of the golden mean.
第2题
建立如下m文件
function day=dayofweek(x)
d=x(1);m=mod(x(2)-2,12);
yy=x(3);
if m>10
yy=yy-1;
end
y=rem(yy,100);
c=floor(yy/100);
switch mod(1+(floor(2.6*m -0.2)+d+y+floor(y/4)+floor(c/4)-2*c),7)
case 1
day='Sunday';
case 2
day='Monday';
case 3
day='Tuesday';
case 4
day='Wednesday';
case 5
day='Thursday';
case 6
day='Friday';
case 0
day='Saturday';
end
下面是例子
在命令行里面敲
dayofweek([8 6 2008])
屏幕就会显示
ans =
Sunday
一个作业中的问题(后天我就要交了,
( )的人流 后天就要上课交作业了.
六年级下册课外作业51页《父亲》课后的练习题.后天就要交作业了,急,
后天就要交作业了,好人一生平安
煤、石油、天然气的尚余储藏量与估计开采年限?(作业后天就要交了,
求matlab 用Bezier曲线绘制一个兔子的图案~后天就要交了!带源程序代码!
生物中的几道问题,很急啊,后天就要交作业啦
谁能写一篇钓鱼的作文,后天就要交了!
《中华上下五千年》400字读后感.后天就要交作业了,
谁有中国国家博物馆的观后感?(400-500字) 我后天就要交作业
你的好朋友生病了,你去看望他你,该说些什么安慰的话呢?急.后天就要交作业了.
跪求那一刻 她或他很美的作文,明天就要交作业了