MATLAB绘图函数代码及图形

上传人:灯火****19 文档编号:122002432 上传时间:2020-02-29 格式:PDF 页数:12 大小:333.06KB
返回 下载 相关 举报
MATLAB绘图函数代码及图形_第1页
第1页 / 共12页
MATLAB绘图函数代码及图形_第2页
第2页 / 共12页
MATLAB绘图函数代码及图形_第3页
第3页 / 共12页
MATLAB绘图函数代码及图形_第4页
第4页 / 共12页
MATLAB绘图函数代码及图形_第5页
第5页 / 共12页
点击查看更多>>
资源描述

《MATLAB绘图函数代码及图形》由会员分享,可在线阅读,更多相关《MATLAB绘图函数代码及图形(12页珍藏版)》请在金锄头文库上搜索。

1、 第一题 定积分 极限 微分 function y f1 F 1 while F 0 syms x y z F input 请输入表达式 变量为x y z 退出 0 if F 0 Sel input 请选择要进行的计算 1 微分 2 极限 3 定积分 其他 返回 switch Sel case 1 Var input 请输入进行微分的变量 N input 请输入阶数 disp 结果为 diff F Var N case 2 Var input 请输入进行极限的变量 Val input 请输入极限要趋近的值 disp 结果为 limit F Var Val case 3 Var input 请输

2、入积分变量 Val 1 input 请输入积分下限 Val 2 input 请输入积分上限 disp 结果为 int F Var Val 1 Val 2 end end F input 0 退出 其他 继续 end 第二题 矩阵的运算 function y f2 syms result while 1 disp disp 1 Add disp 2 Sub disp 3 Multi disp 4 Divide disp 0 Exit ch input Choose an item to continue if ch 0 return end M1 input Enter the first Ma

3、trix M2 input Enter the second Matrix switch ch case 1 result M1 M2 case 2 result M1 M2 case 3 result M1 M2 case 4 result M1 M2 end disp The result is disp result end End function 第三题 矩阵的操作 function y f3 while 1 disp disp 1 转置 disp 2 求秩 disp 3 求逆 disp 4 行列式 disp 0 Exit ch input Choose an item to con

4、tinue if ch 0 return end M input Enter the Matrix switch ch case 1 result M case 2 result rank M case 3 result inv M case 4 result det M end disp The transform result is disp result end End function end end end 第四题 向量的判定 function y f4 vec 1 vec 2 dem 1 vec 1 input 第一个向量 vec 2 input 第二个向量 Sel 2 input

5、 选择 1 判断两向量是否共线 2 判断三向量是否共面 if Sel 2 1 A vec 1 vec 2 if rank A 1 disp 两向量共线 else disp 两向量不共线 end else if Sel 2 2 vec 3 input 请输入第三个向量 dem 3 length vec 3 if dem 3 dem 1 if cro vec 1 vec 2 vec 3 0 disp 三向量共面 else disp 三向量不共面 end else disp 输入向量维数不一致 end end end 第五题 向量的长度 方向角的计算 点积 叉积 混合积及投影的计算 function

6、 y f5 n 1 while n 0 vec 1 input 请输入第一个向量 dem 1 length vec 1 Sel input 请选择 1 计算向量的方向角 长度 2 计算向量其他运算 其他 返回 if Sel 2 vec 2 input 请输入第二个向量 dem 2 length vec 2 if dem 1 dem 2 Sel 1 input 请选择运算 1 点积 2 向量积 三维 3 投影 三维 4 混合积 三维 5 判断共线 共面 switch Sel 1 case 5 JUDGE vec 1 vec 2 dem 1 case 1 vec 1 vec 2 case 2 PA

7、N vec 1 vec 2 case 3 vec 1 vec 2 sqrt vec 2 vec 2 case 4 vec 3 input 请输入第三个向量 三维 dem 3 length vec 3 if dem 3 dem 1 A PAN vec 1 vec 2 vec 3 else disp 维数不一致 end end else disp 输入错误 end else if Sel 1 disp 模为 Mol sqrt vec 1 vec 1 A eye dem 1 m 1 while m dem 1 1 acos A m vec 1 sqrt A m A m Mol 180 pi m m

8、1 end else n 0 end end Sel input 继续计算向量的长度 方向角的计算 向量的点积 叉积 混合积及投影 1 退出 2 if Sel 2 n 0 end end 第六题 点到直线 平面的距离的计算 function y f6 n 1 while n 0 Point input 请输入一个三维点坐标向量 Sel input 请选择 1 点到直线的距离 2 点到面的距离 switch Sel case 1 LinVec input 请输入直线方程的方向向量 三维 LinPot input 请输入直线方程所经过的点 三维 if length LinVec length Li

9、nPot b 20 c 10 x y meshgrid 2 0 1 2 2 0 1 2 xa x 2 a 2 yb y 2 b 2 xyz ones size x xa yb c 2 z xyz 0 5 mesh x y z 第八题 双曲抛物面 function pic2 a 5 b 5 x y meshgrid 2 0 1 2 2 0 1 2 xa x 2 a 2 yb y 2 b 2 z yb xa mesh x y z 第九题 椭圆抛物面 function y pic3 a 2 b 2 x y meshgrid 2 0 1 2 2 0 1 2 xa x 2 a 2 yb y 2 b 2

10、z xa yb mesh x y z 第十题 单页双曲面 function y pic4 theta 0 pi 20 2 pi rho 1 0 05 3 theta rho meshgrid theta rho r sqrt rho 2 1 x y z pol2cart theta rho r figure 1 surf x y z hold on z z surf x y z axis off 第十一题 双叶双曲面 function k pic5 t1 2 pi 0 05 2 pi t2 1 pi 0 05 1 pi t1 t2 meshgrid 2 pi 0 05 2 pi 1 pi 0

11、05 1 pi z 0 2 sqrt sin t2 sin t2 1 h1 mesh 2 cos t1 sin t2 sin t1 sin t2 z hold on h2 mesh 2 cos t1 sin t2 sin t1 sin t2 z 第十二题 椭圆锥面 function k tupian4 x y x 3 0 01 3 y 2 0 01 2 x y meshgrid 3 0 01 3 2 0 01 2 z sqrt x 3 2 y 2 2 mesh x y z hold on mesh x y z 第十三题 常见二维图形 theta 0 0 1 2 pi figure 1 rho

12、2 theta polar theta rho title r at t 2 pi 0 1 2 pi figure 1 x 2 t sin t y 2 1 cos t plot x y g xlabel x ylabel y title 摆线 theta 0 0 1 10 pi figure 1 rho sqrt 4 sin 2 theta polar theta rho g hold on rho rho polar theta rho g legend r 2 a 2sin2t 2 hold on rho sqrt 4 cos 2 theta polar theta rho r hold

13、on rho rho polar theta rho r legend r 2 a 2cos2t 2 theta 0 0 1 4 pi figure 1 rho exp 0 2 theta polar theta rho title r exp at x 5 0 1 5 y 1 sqrt 2 pi exp x 2 2 figure 1 plot x y g xlabel x ylabel y title 概率曲线 t 0 0 1 2 pi figure 1 x 2 cos t 3 y 2 sin t 3 plot x y g xlabel x ylabel y title x 2 3 y 2

14、3 a 2 3 theta 0 0 1 2 pi figure 1 rho 2 cos 3 theta polar theta rho g legend r asin3t 4 hold on rho 2 sin 3 theta polar theta rho r legend r acos3t theta 0 0 1 2 pi figure 1 rho 2 cos 2 theta polar theta rho g legend r acos2t 4 t 0 0 1 2 pi figure 1 x 2 cos t y 2 sin t plot x y g xlabel x ylabel y t

15、itle x 2 a 2 y 2 b 2 1 theta 0 0 1 2 pi figure 1 rho 2 1 cos theta polar theta rho title r a 1 cos t x 1 1 20 1 figure 1 subplot 2 2 1 y asin x plot x y g title asin x axis 1 1 2 2 subplot 2 2 2 y acos x plot x y g title acos x axis 1 1 0 4 subplot 2 2 3 y atan x plot x y g title atan x hold on y y

16、pi plot x y hold on y y 2 pi plot x y axis 1 5 1 5 4 4 subplot 2 2 4 y atan x plot x y g title acot x x x y y pi 2 plot x y hold on y y pi plot x y hold on y y 2 pi plot x y axis 1 5 1 5 pi 2 pi x 5 0 1 5 y 8 2 3 x 2 4 2 2 figure 1 plot x y g hold on x 2 0 1 2 y sqrt 4 x 2 2 plot x y r hold on y sqrt 4 x 2 2 plot x y r xlabel x ylabel y title y 8a 3 x 2 4a 2 y 5 0 1 5 figure 1 x 2 1 y 2 0 5 plot x y g hold on x x plot x y g xlabel x ylabel y title x 2 a 2 y 2 b 2 1 x 2 0 1 2 figure 1 subplot 2 4

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 中学教育 > 教学课件 > 初中课件

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号