MatLab数据可视化与分析:从图形绘制到概率应用
1. MatLab图形绘制
MatLab的图形功能十分强大,但要充分利用这些功能,需要学习大量看似令人困惑的函数。下面通过一些示例来深入了解。
1.1 绘制正弦波数据
首先,创建示例数据 d1 和 d2 ,并将它们绘制在图形窗口中。以下是具体的代码:
% create sample data, d1 and d2
N = 51;
Dt = 1.0;
t = [0:N-1]';
tmax = t(N);
d1 = sin(pi*t/tmax);
d2 = sin(2*pi*t/tmax);
% plot the sample data
figure(7);
clf;
set(gca,'LineWidth',2);
hold on;
axis xy;
axis([0, tmax, -1.1, 1.1]);
plot(t,d1,'k-','LineWidth',2);
plot(t,d2,'k:','LineWidth',2);
title('data consisting of sine waves');
xlabel('time');
ylabel('data');
上述代码的操作步骤如下:
1. 创建时间变量 t 和两个数据变量 d1 、 d2 ,它们分别是正弦波 sin(pt/L) 和 sin(2pt/L)
超级会员免费看
订阅专栏 解锁全文

6

被折叠的 条评论
为什么被折叠?



