用if编写的函数文件程序清单第三次试验Word文档格式.docx

上传人:b****5 文档编号:21498135 上传时间:2023-01-30 格式:DOCX 页数:11 大小:15.75KB
下载 相关 举报
用if编写的函数文件程序清单第三次试验Word文档格式.docx_第1页
第1页 / 共11页
用if编写的函数文件程序清单第三次试验Word文档格式.docx_第2页
第2页 / 共11页
用if编写的函数文件程序清单第三次试验Word文档格式.docx_第3页
第3页 / 共11页
用if编写的函数文件程序清单第三次试验Word文档格式.docx_第4页
第4页 / 共11页
用if编写的函数文件程序清单第三次试验Word文档格式.docx_第5页
第5页 / 共11页
点击查看更多>>
下载资源
资源描述

用if编写的函数文件程序清单第三次试验Word文档格式.docx

《用if编写的函数文件程序清单第三次试验Word文档格式.docx》由会员分享,可在线阅读,更多相关《用if编写的函数文件程序清单第三次试验Word文档格式.docx(11页珍藏版)》请在冰豆网上搜索。

用if编写的函数文件程序清单第三次试验Word文档格式.docx

-1&

x<

-0.5

y='

00'

;

elseifx>

-0.5&

01'

elseifx>

0&

0.5

10'

elsey='

11'

end

用switch编写的一个函数文件程序清单:

functiony=encode_switch(x)

%encode_switch:

y=encode_switch(x)

switchfloor(2*x)

case-2

case-1

case0

case1

otherwise

);

编程计算fibnacci序列,f

(1)=1,f

(2)=2,f(i+2)=f(i)+f(i+1),i≥1

(1)用for循环计算前序列的前50个值

%用for循环计算前序列的前50个值

fori=1:

50

f(i+2)=f(i)+f(i+1);

f(i)

(2)

%用while循环计算序列中所有样值小于5000的部分

f

(1)=1,f

(2)=1;

f(3)=f

(2)+f

(1);

i=1;

whilef(i)<

=5000

f(i+2)=f(i)+f(i+1);

i=i+1;

f(i-1)

Togetstarted,selectMATLABHelporDemosfromtheHelpmenu.

Theelementtype"

name"

mustbeterminatedbythematchingend-tag"

<

/name>

"

.

Couldnotparsethefile:

c:

\matlab7\toolbox\ccslink\ccslink\info.xml

>

diaryexp3

E=[{1},{1,2,3,4,5},{rand(2,2)},{'

babcdefgh>

$@8*_+|SaL{}"

?

'

}]

E=

[1][1][2][3][4][5][2x2double][1x25char]

celldisp(E)

E{1}=

1

E{2}=

E{3}=

2

E{4}=

3

E{5}=

4

E{6}=

5

E{7}=

0.95010.6068

0.23110.4860

E{8}=

student_1=struct('

number'

'

20080101'

name'

张三'

sex'

女'

age'

18)

student_1=

number:

'

name:

sex:

age:

18

student_2.number=20080102

student_2=

20080102

student_2.name='

王五'

student_2.sex='

student_2.age=18

student_3=struct('

20080103'

张四'

男'

19)

student_3=

19

student_4=struct('

20080104'

张六'

student_4=

student_1.name

ans=

张三

student_3.sex

student_4.age

edit

Inputargument"

x"

isundefined.

Errorin==>

encodeat7

y=encode(-0.7)

y=

00

y=encode(-0.2)

01

x=0.2;

10

x=0.8;

11

y=encode_switch(-0.7)

y=encode_switch(-0.2)

f=

Columns1through7

11235813

Columns8through14

21345589144233377

Columns15through21

610987159725844181676510946

8

13

21

34

55

89

144

233

377

610

987

1597

2584

4181

edit

6765

10946

17711

28657

46368

75025

121393

196418

317811

514229

832040

1346269

2178309

3524578

5702887

9227465

14930352

24157817

39088169

63245986

102334155

165580141

267914296

433494437

701408733

1.1349e+009

1.8363e+009

2.9712e+009

4.8075e+009

7.7787e+009

1.2586e+010

diaryoff

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 初中教育 > 语文

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1