教学文库网 - 权威文档分享云平台
您的当前位置:首页 > 文库大全 > 小学教育 >

MatLab考试题题库(必做题)(带答案)(2)

来源:网络收集 时间:2026-04-27
导读: 2. (1) Using plot() function to plot the curves of 2[sin(2)cos3]e x y x x -=+ and sin x z x = in the range of []2,2x ππ∈-, let their color are red and green respectively, and add the grid to the f

2. (1) Using plot() function to plot the curves of

2[sin(2)cos3]e x y x x -=+ and sin x z x

= in the range of []2,2x ππ∈-, let their color are red and green respectively, and add the grid to the figure.

(2) Using fplot() function and ezplot() function to plot above-mentioned (上述的) curves respectively.

(1)x=-2*pi:pi/100:2*pi;

y=(sin(2*x)+cos(3*x)).*exp(-2*x);

z=sin(x)/x;

plot(x,y,’r ’,x,z,’g ’)

(2)fplot('[(sin(2*x)+cos(3*x)).*exp(-2*x), sin(x)/x]',[-2*pi 2*pi])

3. Plot the 3D mesh figure and 3D surface figure of the function

222/2(1)(,)9(1)e x y f x y x --+=-

in the range of 44x -≤≤ and 44y -≤≤, respectively.

x=-4:1/100:4;

y=-4:1/100:4;

z=9(1-x)^2*exp(-x ’^2/2-(y ’+1)^2)

mesh(x,y,z);

surf(x,y,z);

四.综合编程题(每小题11分,共22分)

1. Write a function program to compute the following function

1.8|2|!,()f1(x)34sin(2),i x i x x =?=?+?整数其他

and call this function program to compute the value of y=f1(-4)+f1(3)-f1(14.37) in main program or command window, there, ||!i shows the factorial (阶乘) of ||i .

提示:对x 取整的函数有fix(x), floor(x), round(x) 和ceil(x) .

fuction y=f1(x) %

if x-fix(x)= =0

y=prod(1:abs(2*x));

else

y=4*sin(2*x)+x^;

y=f1(-4)+f1(3)-f1

2. Write a program to compute the sample mean

1

1xbar ==n

i i x x n =∑, and the sample skewness (偏度)

31

1ske ()n

i i x x n ==-∑ . for the following three case:

(1) n and ],,,[21n x x x x Λ= exist in Workspace of Matlab. It is no any limit;

(2) n and ],,,[21n x x x x Λ= are unknown variables. Please input x by keyboard one by one, and give a mark of end the data input. Examinees can use loop statement and length() function and input() function, but cannot use mean()

function, std() function, and var() function directly (可以使用循环语句和length()函数、input()函数等进行编程,但不能直接使用mean()、std()和var()等函数).

(1)s=0;

for i=1:n

s=s+x(i);

end

xbar=s/n

m=0;

for i=1:n

m=m+(x(i)-xbar)^3;

end

ske=m/n

(2)x(1)=input('请输入x ');

i=1;s=0;

while(x(i)~='a')

s=s+x(i);

i=i+1;

x(i)=input('请输入x ,输’a’结束');

end

xbar=s/(i-1)

m=0;

for j=1:i-1

m=m+(x(i)-xbar)^3;

end

ske=m/(i-1)

三,

产生一个1x10的随机矩阵,大小位于(-5 5),并且按照从大到小的顺序排列好!(注:要程序和运行结果的截屏)

答案:

a=10*rand(1,10)-5;

b=sort(a,'descend')

1.请产生一个100*5的矩阵,矩阵的每一行都是[1 2 3 4 5]

2. 已知变量:A=’ilovematlab’;B=’matlab’, 请找出:

(A) B在A中的位置。

(B)把B放在A后面,形成C=‘ilovematlabmatlab’

3. 请修改下面的程序,让他们没有for循环语句!

A=[1 2 3; 4 5 6; 7 8 9];

[r c]=size(A);

for i=1:1:r

for j=1:1:c

if (A(i,j)>8 | A(i,j)<2)

A(i,j)=0;

end

end

end

4. 请把变量A=[1 2 3; 4 5 6; 7 8 9]写到文件里,写完后文件看起来是这样的

1 2 3 4 5 6 7 8 9

5.试从Yahoo网站上获得微软公司股票的2008年9月的每日收盘价。

6.编写M文件,从Yahoo网站批量读取至在2008年9月份的每日收盘价(提示:使用字符串函数)。

7. 将金牛股份(000937)2005年12月14日至2006年1月10日的交易记录保存到Excel中,编写程序将数据读入MATLAB中,进一步将数据读入Access数据库文件。

8.已知资产每日回报率为,标准差为,资产现在价值为亿,求5%水平下资产的10天在险价值(Var)。

=[1 2 3 4 5],b=a(1)*a(5)+a(2)*a(4)+a(3)*a(3)+a(4)*a(2)+a(5)*a(1).试用MATLAB中最简单的方法计算b,注意最简单哦。

1、求下列联立方程的解

3x+4y-7z-12w=4

5x-7y+4z+ 2w=-3

x +8z- 5w=9

-6x+5y-2z+10w=-8

求系数矩阵的秩;

求出方程组的解。

解:(1)

>> a=[3 4 -7 -12];

5 -7 4 2 ;

1 0 8 -5;

-6 5 -2 10];

c=[4; -3; 9;-8];

b=rank(a)

b = 4

(2)>> d=a\c

d = , , ,

即: x=;y= ;z= ;w=

2、设y=cos[+((3sinx)/(1+x^2))]把x=0~2π间分为101点,画出以x为横坐标,y为纵坐标的曲线;

…… 此处隐藏:1095字,全部文档内容请下载后查看。喜欢就下载吧 ……
MatLab考试题题库(必做题)(带答案)(2).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.jiaowen.net/wenku/40683.html(转载请注明文章来源)
Copyright © 2020-2025 教文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:78024566 邮箱:78024566@qq.com
苏ICP备19068818号-2
Top
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)