【Matlab的灵魂是绘图】除了不会生孩子 MATLAB 什么都会

平抛运动
clear;clc;figure
vx =50;         %初速度
t =0:0.001:10;  %时间向量
x = vx*t;       %x方向
y =-9.8*t.^2/2; %y方向
comet(x,y)      %

在这里插入图片描述

   clear;clc;figure
   vx =100*cos(1/4*pi);
   vy =100*sin(1/4*pi);
   t =0:0.001:15;
   x = vx*t;
   y =vy*t-9.8*t.^2/2;
  comet(x,y)

在这里插入图片描述

clear;clc;
dt=0.1;t1=0:dt:4*pi
vx=2
vy=sin(t1)
x=vx.*t1
y=1-cos(t1)
figure;
plot(t1,vy)
grid on;axis equal;
figure;
comet(x,y)
grid on;axis equal

在这里插入图片描述

Matlab语言学习

微分,diff 例如
在这里插入图片描述

syms x;
diff(x^2+cos(x))

结果: ans = 2*x - sin(x)
还可以求n阶导数,diff(y,n)

syms x;
y=x^2+cos(x)
diff(y,2)
%ans =  2 - cos(x)

求积分
在这里插入图片描述
在这里插入图片描述

syms x;
int(exp(x)-3*cos(x))
% ans = exp(x) - 3*sin(x)

计算y=sin(x),x从0到pi

syms x;
int(sin(x),0,pi)
% ans =2

matlab如何画两个图,用plot命令的时候

https://www.cnblogs.com/haore147/p/3633017.html
https://blog.csdn.net/xkl7111/article/details/17223617
hold on;就可以啦,然图像保持不被替代。

在同一个窗口画两张图的话,用subplot,例:
figure(1);
subplot(1,2,1);
plot(…);
subplot(1,2,2);
plot(…);

在不同的窗口中画两张图,用figure,例:
figure(1);
plot(…);
figure(2);
plot(…);

弧度角度

matlab中算的三角函数都是弧度,其实很多专业软件都是用弧度来表示,我们在使用过程中需要注意这一点。简单的加个d搞定。
在这里插入图片描述
改刻度;

figure;
axes;
axis([0 100 0 1000])
set(gca,'XTick',0:20:100);
set(gca,'YTick',0:200:1000);

在这里插入图片描述

按比例输出图像坐标轴 axis equal
x = linspace(0,8*2000, 10000);
y=400*sin(2*pi*x/2000)
plot(x,y)
axis equal

在这里插入图片描述

matlab逻辑判断。

a = input('输入一个数:');
b = input('输入一个数:');
if a > 2 && b <= 7
    disp('a > 2 && b <= 7');
else 
    disp('否(a > 2 && b <= 7)');
end

求a中小于4的集合。

a=[18,2,3,23,5,6]
c=a(a>4)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值