📄 plotall.m
字号:
%read file 'x_input.bin', 'y_output.bin' and 'y_estimate.bin'
%plot x[n] vs y[n], y[n] vs y_est[n] and error y_err[n]
x = [1:3000];
y = [1:3000];
y3 = [1:1000];
y_est = [1:1000];
y_err = [1:1000];
t = [1:1000];
fid0 = fopen('x_input.bin', 'r');
x = fread(fid0, 4000, 'double'); %read 4000 samples x[0] - x[3999]
fclose(fid0);
fid1 = fopen('y_output.bin', 'r');
y = fread(fid1, 4000, 'double'); %read 4000 sample y[0] - y[3999]
fseek(fid1, 8*2000, 'bof'); %skip the first 2000 samples
y3 = fread(fid1, 1000, 'double'); %read sample y[2000] - y[2999]
fclose(fid1);
fid2 = fopen('y_estimate.bin', 'r');
y_est = fread(fid2, 1000, 'double'); %read 1000 estimated ~y[n]
fclose(fid2);
%calculate error
y_err = y3 - y_est;
%plot input x[n] and output y[n]
figure(1);
subplot(2,1,1);
plot(x);
title('Input x[n]');
ylabel('Amplitude');
subplot(2,1,2);
plot(y);
title('Output y[n]');
xlabel('Time');
ylabel('Amplitude');
%plot y[2000]-y[2999], y_est[n] and error y_err[n]
figure(3);
subplot(2,1,1);
plot(t, y3, '-');
title('Output y[n]');
ylabel('Amplitude');
subplot(2,1,2);
plot(t, y_est,'r-', t, y_err,'g-');
title('Estimation ~y[n] and error');
xlabel('Time');
ylabel('Amplitude');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -