clear all
clc
%% 俩百分号加一个空格可以分块
% 一个百分号可以注释本行
abs(char)
char(num)
A=[1 2 3; 4 5 2; 3 2 7]
B=A'
C=A(:)%拉直A,竖着拉的
D=inv(A)
A=cell(1,6)
A{2}=eye(3)%3*3单元矩阵
A{5}=magic(5)%幻方
B=A{5}
%matlab从1开始
books=struct('name',{{'text','text'}},'price',[30 40])
books.name
books.name(1)%cell
books.name{1}%字符串
A=[1 2 3 5 8 5 4 6]
B=1:2:9
C=repmat(B,3,1)%纵横重复几次
D=ones(2,4)%生成全是1的矩阵 (行,列)
A=[1 2 3 4; 5 6 7 8]
B=[1 1 2 2; 2 2 1 1]
C=A+B
D=A-B
E=A*B'
F=A.*B%对应项相乘
G=A/B
H=A./B
A=magic(5)
B=A(2,3)
C=A(3,:)
D=A(:,4)
[m,n]=find(A>20)%找大于20的序列值/矩阵
x=0:0.01:2*pi
y=sin(X)
figure
plot(x,y)
title('y=sin(x)')
xlabel('x')
ylabel('sin(x)')
xlim([0 2*pi])
x=0:0.01:20;
y1=200*exp(-0.05*x).*sin(x);
y2=0.8*exp(-0.5*x).*sin(10*x);
figure
[AX,H1,H2]=plotyy(x,y1,x,y2,'plot');
set(get(AX(1),'Ylabel'),'String','Slow Decay')
set(get(AX(2),'Ylabel'),'String','Fast Decay')
xlabel('Time (\musec)')
title('Multiple Decay Rates')
set(H1,'LineStyle','--')
set(H2,'LineStyle',':')
%三维绘图
t=0:pi/50:10*pi;
plot3(sin(t),cos(t),t)
xlabel('sin(t)')
ylabel('cos(t)')
zlabel('t')
hold on
grid on
axis square%变成正方形
编辑->复制图形
另存为->保存
[x,y,z]=peaks(30)
mesh(x,y,z)
grid
标签:set,20,name,建模,books,数学,pi,sin
From: https://www.cnblogs.com/liangqianxing/p/17060480.html