Matlab计算学习笔记

Matlab计算学习笔记

1.矩阵运算操作
生成行与列的操作:

A=[1 2 3 4] ;     %生成行
A=[1;2;3;4];        %生成列

2.从键盘中输入数据

 a=input('please input a : ' )
please input a : 6

a =

     6

3.设置输入输出格式
在这里插入图片描述
4.绘图

>> y1=x1.^2;
>> x2=0:0.5:10;
>> y2=2*x2+3;
>> plot(x1,y1,x2,y2)

在这里插入图片描述

function ex0101()
x=0:pi/15:2*pi;
y1=0.5*x.^2;
y2=10*sin(x);
plot(x,y1,'r.-',x,y2');       %画图
grid                          %网格线
xlabel('variable x')          %横坐标
ylabel('x^2 and sin(x)')      %纵坐标
title('x^2 and sin(x)');      %标题
text(6.2,-5.5,'sin(x)');      %在坐标6.2-5.5处标注y2
text(6.2,16,'x^2');           %在坐标6.216处标注y1

在这里插入图片描述

function ex0102()
x=0:pi/15:2*pi;
y1=0.5*x.^2;
y2=10*sin(x);
y3=exp(x);
y4=cos(x);
subplot(2,2,1);                       %拆分为2*2个区域分别在各个区域画图
plot(x,y1);       %画图
title('0.5x^2');
subplot(2,2,2);                      
plot(x,y2);       %画图
title('0.1*sin(x)');
subplot(2,2,3);                       %拆分为2*2个区域分别在各个区域画图
plot(x,y3);       %画图
title('exp(x)');
subplot(2,2,4);                      
plot(x,y4);       %画图
title('cos(x)');

在这里插入图片描述
5.三维图形绘图学习

function ex0103()
t=0:pi/50:6*pi;
xt=exp(-0.1*t).*cos(t);
yt=exp(-0.1*t).*sin(t);
subplot(2,2,1);                       %拆分为2*2个区域分别在各个区域画图
plot3(xt,yt,t);       %画图
grid on
title('xy yt t 的三维图');
subplot(2,2,2);                      
plot3(xt,yt,t);       %画图
grid on
title('在(1,0,0)的三维图');
view([1 0 0]);      %观测在 (0,0,1)的三维图

subplot(2,2,3);                      
plot3(xt,yt,t);       %画图
grid on
title('在(0,0,1)的三维图');
view([0 0 1]);      %观测在 (0,0,1)的三维图
subplot(2,2,4);                      
plot3(xt,yt,t);       %画图
grid on
title('在(0,-1,0)的三维图');
view([0 -4 0]);      %观测在 (0,0,1)的三维图

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值