function diff_err_energy = difff(data0, data1, Title0, Title1, option)
% Plots two complex functions, their difference and ratio; plus a few
% other stats like max min of the difference and ratio, and SNR.
%
% difff(datain, dataout);
% difff(datain, dataout, Title0, Title1);
% difff(datain, dataout, Title0, Title1, 1); % real data only
% DiffErrEnergy = difff(data0, data1, Title0, Title1)
% data0, data1 Complex data vectors
% Title0, Title1 Character string names used in graph titles for
% the two data vectors.
% option 1 Compare only *real* portions of input data
% Engineer: Amey Kulkarni
% Module Name: difff
% Project Name: Fast Fourier Transform (16-point)
% 06/03/11 Inverted dB calculation ratio so output is positive (SNR)
% 01/06/20 Added optional diff_err_energy output
% 01/04/11 Added option=1 for real-only input data
% 01/01/02 Fixed separated mean part so it doesn't give 'Rank deficient' error
% 00/06/07 Added Title0 and Title1 arguments.
% 00/05/23 Added check for log(0)
% Sped up calculation of Energy (oops, should've done it before)
% Sped up plotting of ratio (oops, should've done it before)
% 00/05/19 Added mean of ratio; needs work for when data1 == 0
% 00/04/06 Added energy, SNR
% 00/01/28 Added plot of data0-data1
% I can't get rid of that crazy "Warning:...axis limit..." message
% that shows up sometimes! axis([...]) arguments are fine! Grr.
% 99/12/17 Cleaned up ratio stuff when undefined
% 99/12/10 Written
%--- Check inputs
if (length(data0) ~= length(data1))
fprintf('Warning: difff(): data0 and data1 are different lengths\n');
end
% Set default titles if needed
if (nargin == 2)
Title0 = 'data 0';
Title1 = 'data 1';
end
if (nargin == 3)
Title1 = 'data 1';
end
if (nargin == 5)
if (option ~= 1)
fprintf('Error: difff(): Illegal option value\n');
return;
end
else
option = 0;
end
%--- Init
% Resize inputs if they're of different lengths
len0 = length(data0);
len1 = length(data1);
if len0 == len1
len = len0;
else
len = min(length(data0), length(data1));
temp = data0; clear data0; data0 = temp(1:len);
temp = data1; clear data1; data1 = temp(1:len);
clear temp;
end
min_r = +inf;
min_i = +inf;
max_r = -inf;
max_i = -inf;
clf;
%--- Calculate stuff
errR = real(data0)-real(data1);
errI = imag(data0)-imag(data1);
err = data0-data1;
if (option ~= 1) % complex data
Energy_data0 = sum(abs(data0.^2));
Energy_diff = sum(abs(err.^2));
else % real-only data
Energy_data0 = sum(abs(real(data0).^2));
Energy_diff = sum(abs(real(err).^2));
end
%--- plot data0
subplot(4,1,1);
plot(0:len-1, real(data0), 'r'); hold on;
if (option ~= 1)
plot(0:len-1, imag(data0), 'b'); end
axis tight; grid on; title(Title0);
%--- plot data1
subplot(4,1,2);
plot(0:len-1, real(data1), 'r'); hold on;
if (option ~= 1)
plot(0:len-1, imag(data1), 'b'); end
axis tight; grid on; title(Title1);
%--- plot difference
subplot(4,1,3);
plot(0:len-1, errR, 'rx'); hold on;
if (option ~= 1)
plot(0:len-1, errI, 'bo'); end
axis tight; grid on; title(strcat('(', Title0, ') - (', Title1, ')'));
%--- plot ratio
subplot(4,1,4);
%for j=1:len,
% if real(data1(j)) ~= 0 % Real part
% ratio = real(data0(j))/real(data1(j));
% plot(j-1, ratio, 'rx');
% if ratio < min_r min_r = ratio; end
% if ratio > max_r max_r = ratio; end
% if j == 1 hold on; end
% end
% if imag(data1(j)) ~= 0 % Imag part
% ratio = imag(data0(j))/imag(data1(j));
% plot(j-1, ratio, 'bo');
% if ratio < min_i min_i = ratio; end
% if ratio > max_i max_i = ratio; end
% if j == 1 hold on; end
% end
%end
% Improved vectorized method
denom = real(data1);
temp = find(denom == 0);
denom(temp) = 1; % temporary to do division
ratio = real(data0)./denom;
ratio(temp) = Inf; % Inf when ratio==infinity
plot(0:len-1, ratio, 'rx');
hold on;
if (option ~= 1)
denom = imag(data1);
temp = find(denom == 0);
denom(temp) = 1; % temporary to do division
ratio = imag(data0)./denom;
ratio(temp) = Inf; % Inf when ratio==infinity
plot(0:len-1, ratio, 'bo');
end
%axis([0 len-1 min(min_r, min_i)/1.05 max(max_r, max_i)*1.05]);
axis tight;
grid on;
title(strcat('(', Title0, ') \div (', Title1, ...
'); Points not plotted if ratio is \infty'));
%----- Print some stats
fprintf('max(data0-data1) = ');
fprintf(' %+f', max(real(data0)-real(data1)));
fprintf(' %+fi = ', max(imag(data0)-imag(data1)));
fprintf(' %+g', max(real(data0)-real(data1)));
fprintf(' %+gi\n', max(imag(data0)-imag(data1)));
fprintf('min(data0-data1) = ');
fprintf(' %+f', min(real(data0)-real(data1)));
fprintf(' %+fi = ', min(imag(data0)-imag(data1)));
fprintf(' %+g', min(real(data0)-real(data1)));
fprintf(' %+gi\n', min(imag(data0)-imag(data1)));
fprintf('max(data0/data1) = %+f', max_r);
fprintf(' %+fi\n', max_i);
fprintf('min(data0/data1) = %+f', min_r);
fprintf(' %+fi\n', min_i);
numer = real(data0);
denom = real(data1);
temp = find(denom == 0);
denom(temp) = 1; % temporary to do division
ratio = numer ./ denom;
ratio(temp) = 0; % introduces error, should remove sample
fprintf('approx separated mean(data0/data1) = %+f', mean(ratio));
numer = imag(data0);
denom = imag(data1);
temp = find(denom == 0);
denom(temp) = 1; % temporary to do division
ratio = numer ./ denom;
ratio(temp) = 0; % introduces error, should remove sample
fprintf('+ %+fi\n', mean(ratio));
%----- Print more stats: energy, SNR
fprintf('Energy_data0 = %f\n', Energy_data0);
fprintf('Energy_diff = %f\n', Energy_diff);
if Energy_diff ~= 0
fprintf('Energy_data0/Energy_diff = %f', Energy_data0/Energy_diff);
fprintf(' = %fdB', 10*log10(Energy_data0/Energy_diff));
fprintf('\n');
end
%----- Return
if (nargout == 1)
diff_err_energy = Energy_diff;
end
没有合适的资源?快使用搜索试试~ 我知道了~
毕业设计&课设-开发了16点FFT,以便对MATLAB函数的FFT进行精确建模。该模块使用verilog testbe.zip
![preview](https://csdnimg.cn/release/downloadcmsfe/public/img/white-bg.ca8570fa.png)
共30个文件
m:16个
v:8个
png:4个
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
需积分: 0 0 下载量 69 浏览量
2024-01-08
23:06:05
上传
评论
收藏 45KB ZIP 举报
温馨提示
matlab算法,工具源码,适合毕业设计、课程设计作业,所有源码均经过严格测试,可以直接运行,可以放心下载使用。有任何使用问题欢迎随时与博主沟通,第一时间进行解答! matlab算法,工具源码,适合毕业设计、课程设计作业,所有源码均经过严格测试,可以直接运行,可以放心下载使用。有任何使用问题欢迎随时与博主沟通,第一时间进行解答! matlab算法,工具源码,适合毕业设计、课程设计作业,所有源码均经过严格测试,可以直接运行,可以放心下载使用。有任何使用问题欢迎随时与博主沟通,第一时间进行解答! matlab算法,工具源码,适合毕业设计、课程设计作业,所有源码均经过严格测试,可以直接运行,可以放心下载使用。有任何使用问题欢迎随时与博主沟通,第一时间进行解答! matlab算法,工具源码,适合毕业设计、课程设计作业,所有源码均经过严格测试,可以直接运行,可以放心下载使用。有任何使用问题欢迎随时与博主沟通,第一时间进行解答! matlab算法,工具源码,适合毕业设计、课程设计作业,所有源码均经过严格测试,可以直接运行,可以放心下载使用。有任何使用问题欢迎随
资源推荐
资源详情
资源评论
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
共 30 条
- 1
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/1ad39e95093044228d03f0d7ce161a82_zy_dreamer.jpg!1)
![avatar-vip](https://csdnimg.cn/release/downloadcmsfe/public/img/user-vip.1c89f3c5.png)
白话机器学习
- 粉丝: 1w+
- 资源: 7691
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
最新资源
- 课程设计:基于RaspberryPi控制LCD1602显示功能项目源码.zip(教程+源代码+附上详细代码说明)
- Screenshot_20240626_121312.jpg
- mysql安装配置教程 - MySQL 8.0 and macOS
- 我自己的实验模板111
- mysql安装配置教程 - Installing MySQL 5.7 on Windows for Specify
- python图片批量处理器程序
- python Word助手程序
- python超级画板程序
- ProPresenter 是一款专业级别的演示和制作软件,专为教会、现场活动、演唱会、体育赛事和广播等领域设计
- Privazer 是一款强大的隐私保护和系统清理工具
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)