代码拉取完成,页面将自动刷新
%% IV.MATLAB矩阵操作
%%
% 1.矩阵定义与构造
A=[1 2 3 4 5 8 5 4]
B=1:2:9
C=repmat(B,3,2)
D=ones(2,4)
%%
% 2.矩阵的四则运算
A = [1 2 3 4;5 6 7 8]
B = [1 1 2 2;3 3 4 4]
C = A + B
D = A - B
E = A .* B'
F = A .* B
G = A / B
H = A ./ B
%%
% 3.矩阵的下标
A = magic(5)
B = A(2,3)
C = A(3,:)
D = A(:,4)
[m,n] = find(A>10)
%% VII.MATLAB基本绘图操作
%%
%1.二维平面绘图
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.05*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('Mutiple Decay Rates')
set(H1,'LineStyle','--')
set(H2,'LineStyle',':')
%%
% 1.三维立体绘图
t = 0:pi/50:10*pi;
plot3(sin(t),cos(t),t)
xlabel('sin(t)')
ylabel('cos(t)')
zlabel('t')
grid on
axis square
% 2.双峰函数
[x,y,z] = peaks(60);
mesh(x,y,z)
grid
%%
%图形窗口分割
x = linspace(0.2*pi,60);
subplot(2,2,1)%二行二列第一个
plot(x,sin(x)-1);
title('sin(x)-1');axis([0,2*pi,-2,0])
subplot(2,1,2)
plot(x,cos(x)+1);
title('cos(x)+1');axis([0,2*pi,0,2])
subplot(4,4,3)
plot(x,tan(x));
title('tan(x)+1');axis([0,2*pi,-40,40])
subplot(4,4,8)
plot(x,cot(x));
title('cot(x)');axis([0,2*pi,-35,35])
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。