收藏 分享(赏)

matlab实验4MATLAB基本编程.doc

上传人:精品资料 文档编号:9869070 上传时间:2019-09-13 格式:DOC 页数:7 大小:52KB
下载 相关 举报
matlab实验4MATLAB基本编程.doc_第1页
第1页 / 共7页
matlab实验4MATLAB基本编程.doc_第2页
第2页 / 共7页
matlab实验4MATLAB基本编程.doc_第3页
第3页 / 共7页
matlab实验4MATLAB基本编程.doc_第4页
第4页 / 共7页
matlab实验4MATLAB基本编程.doc_第5页
第5页 / 共7页
点击查看更多>>
资源描述

1、实验 4 MATLAB 基本编程一、实验目的1. 熟悉 MATLAB 的脚本编写2. 熟悉 MATLAB 的函数编写3. 熟悉 MATLAB 的变量使用4. 熟悉 MATLAB 的程序控制结构二、实验内容1. 分别选用 if 或 switch 结构实现下述函数表示。-1 x-af(x)= x/a -a-a)y=x/a;elsey=1;endfunction output=function2(x,a)switch xi=i+1;endfunction n=function5()r=input(please input 1 or 2: );switch rcase 1disp(function1(

2、1,2);case 2x=input(input a number:);disp(function3(x);endfunction y=function6()n=input(input a number :);y=1.5;if n=0y=1.5;elsefor x=1:1:ny=3/(y+2);endendfunction y=function7n=input(请输入 n 的值:);a=normrnd(3,9,1,n);y=fliplr(sort(a)function y=function8n=input(n=); x=input(x=); y=0; for i=1:n s=sin(i*x)+

3、(-1)i*cos(i*x); y=y+s; end disp(y);function function9x=input(x=); n=1;y=0; while n=10 s=sin(n*x)+(-1)n*cos(n*x); y=y+s;n=n+1;end disp(y);function y=function10A=1,2,3;0,1,2;0,0,1; n=input(n=); t=input(t=); y=0;for i=1:1:n x=Ai*exp(Ai*t); y=y+x;end disp(y);function y=function11A=1,2,3;0,1,2;0,0,1; n=i

4、nput(n=); t=input(t=); y=0;while(n)x=An*exp(An*t); y=y+x;n=n-1;endy=y+exp(A*t);disp(y);function p=f(x,y)x=input(请输入 x 的值:)y=input(请输入 y 的值:)if y=1p=sin(x);elseif y=2p=cos(x);elsep=sin(x)*cos(x); endfunction f=function13(x,y)switch y case 1f=sin(x);case 2f=cos(x);otherwisef=sin(x)*cos(x);end脚本a=unifrnd(-5,9,1,10);y=sort (a);y=rot90(y)

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

当前位置:首页 > 企业管理 > 管理学资料

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报