Matlab程序设计实验报告材料 下载本文

内容发布更新时间 : 2024/4/23 23:27:37星期一 下面是文章的全部内容请认真阅读。

实用标准文档 n =

10 11 8 9 3.

输入一个百分制成绩,要求输出成绩等级

A、B、C、D、E,其中90~100分为A,80~89分为

B,70~79分为C,60~69分为D,60分以下为E。

function shiyan3 clear; clc;

n=input('please input a number:') n=ceil(n/10) switch n case {10,9} disp('A') case 8 disp('B') case 7 disp('C') case 6 disp('D') case {5,4,3,2,1} disp('E') otherwise

disp('default') end

please input a number:89 n =

89 n =

9 A

4.

硅谷公司员工的工资计算方法如下:

工作时数超过 工作时数低于

(1) (2)

120小时者,超过部分加发15%; 60小时者,扣发700元;

文案大全

实用标准文档 (3)

其余按每小时

84元计发。

试编程按输入的工号和该号员工的工时数,计算应发工资。

function shiyan4 clear; clc; x=0;

m=input('please input your number:') n=input('please input your working hours:') if n<60 x=n*84-700; elseif n>120

x=n*84+(n-120)*84*1.15; else x=n*84; end x

please input your number:38 m = 38

please input your working hours:80 n = 80 x =

6720 5.

设计程序,完成两位数的加、减、乘、除四则运算。即:输入两个两位随机整数,再输入一

个运算符号,做相应的运算,并显示相应的结果。

文案大全

实用标准文档

function shiyan5 clear; clc;

m=input('please input a number:') n=input('please input another number:') x=input('please input a symbol:','s') switch x case '+' q=m+n; case '-' q=m_n; case '*' q=m*n; case '/' q=m/n; end q

please input a number:12 m = 12

please input another number:1 n = 1

please input a symbol:+ x = + 文案大全

实用标准文档 q = 13 6.

建立

5×6矩阵,要求输出矩阵的第n行元素。当n值超过矩阵的行数时,自动转为输出矩

阵的最后一行元素,并给出出错信息。

function shiyan6 clear; clc;

a=[1 2 3 4 5 6;2 3 4 5 6 7;3 4 5 6 7 8;4 5 6 7 8 9;24 45 34 76 23 67]; n=input('please input a number:') if n<=5 b=a(n,:); elseif n>5 b=a(5,:); disp('error'); end b

please input a number:4 n = 4 b =

4 5 6 7 8 9 please input a number:82 n = 文案大全

实用标准文档 82 error b =

24 45 34 76 23 67 7.

产生

20个两位随机整数,输出其中小于平均数的偶数。

function shiyan7 clear; clc;

i=1;c=[];i0=1; a=fix(rand(1,20)*100) b=mean(a) for i=1:20

if(a(i)

a =

Columns 1 through 16

32 89 31 25 43 84 18 50 45 32 38 88 76 88 45 79

Columns 17 through 20

13 6 37 37 b =

47.8000 c =

文案大全

实用标准文档

32 18 32 38 6 >>

文案大全