MATLAB习题,急急急,好心人帮帮忙呀

来源:百度知道 编辑:UC知道 时间:2024/09/26 20:27:16
1、编制一个绘图函数,这个函数有一个gragh参数。调用这个函数时,如果将该函数设置为“sin(x)",生成一个0-2的正弦波形,设置为“cos(x)“,生成一个0-2的余弦波形;设置为”peak“时,生成一个山峰图。
2、用MATLAB求积分。
∫3∏
0
-----------------------------
\ / 4cos(2t)2+sin(t)+1 dt (0≤t≤3∏)

只做了第一题,
function draw(graph)
x=0:pi/15:2*pi;
y1=sin(x);
y2=cos(x);
y3=abs(abs(x-pi)-pi);
switch graph
case 'sin(x)'
plot(x,y1)
case 'cos(x)'
plot(x,y2)
case 'peak'
plot(x,y3)
otherwise
disp('error input')
end
把他存成draw.m就行了