matlab函数accumarray,matlab函数调用问题
各位前辈,程序运行到[E,tt1]=toimage(A,fa,tt,length(tt));报错如下:
??? Error: File: toimage.m Line: 59 Column: 1
This statement is not inside any function.
(It follows the END that terminates the definition of the function "toimage".)
Error in ==> Untitled at 30
[E,tt1]=toimage(A,fa,tt,length(tt));
我感觉到时定义toimage函数时出了问题,但是不知道如何改正,请前辈帮我指点一下,谢谢!程序中的错误我用红色表示了。
全部程序如下:
clear;clc;clf;
N=256;
t=linspace(1,2,N);deta=t(2)-t(1);fs=1/deta;
x=15*sin(2*pi*t*5)+51*sin(2*pi*t*15)+25*sin(2*pi*t*30);
z=x;
c=emd(z);
[imf,ort,nbits]=emd(x,t,[0.05,0.5,0.05]);
L=size(imf,1);
X=0;
for i=1:L;
X=imf(1,:)+X;
end
Y=x-X;
[m,n]=size(c);
for i=1:m;
a=corrcoef(c(i,:),z);
xg(i)=a(1,2);
end
xg;
for i=1:m-1;
mse(i)=mean(c(i,:).^2.2)-mean(c(i,:),2).^2;
end
mmse=sum(mse);
for i=1:m-1;
mse(i)=mean(c(i,:).^2.2)-mean(c(i,:),2).^2;
mseb(i)=mse(i)/mmse*100;
end
hold off
[A,fa,tt]=hhspectrum(c);
[E,tt1]=toimage(A,fa,tt,length(tt));disp_hhs(E,tt1)
figure(4)
for i=1:size(c,1)
faa=fa(i,:);
[FA,TT1]=meshgrid(faa,tt1)
surf(FA,TT1,E)
title('HHT时频谱三维显示')
xlabel('t/s');
ylabel('f/Hz');
zlabel('a/V');
hold on
end
E=flipud(E);
for k=1:size(E,1)
bjp(k)=sum(E(k,:))*1/fs;
end
f=(1:N-2)/N*(fs/2);
[A,f,tt] = hhspectrum(x,t,l,aff)
error(nargchk(1,4,nargin));
if nargin < 2
t=1:size(x,2);
end
if nargin < 3
l=1;
end
if nargin < 4
aff = 0;
end
if min(size(x)) == 1
if size(x,2) == 1
x = x';
if nargin < 2
t = 1:size(x,2);
end
end
Nmodes = 1;
else
Nmodes = size(x,1);
end
lt=length(t);
tt=t((l+1):(lt-l));
for i=1:Nmodes
an(i,:)=hilbert(x(i,:)')';
f(i,:)=instfreq(an(i,:)',tt,l)';
A=abs(an(:,l+1:end-l));
if aff
disprog(i,Nmodes,max(Nmodes,100))
end
end
disp_hhs(im,t,inf)
figure
colormap(bone)
colormap(1-colormap);
if nargin==1
inf=-20;
t = 1:size(im,2);
end
if nargin == 2
if length(t) == 1
inf = t;
t = 1:size(im,2);
else
inf = -20;
end
end
if inf >= 0
error('inf doit etre < 0')
end
M=max(max(im));
im = log10(im/M+1e-300);
inf=inf/10;
imagesc(t,fliplr((1:size(im,1))/(2*size(im,1))),im,[inf,0]);
set(gca,'YDir','normal')
xlabel(['time'])
ylabel(['normalized frequency'])
title('Hilbert-Huang spectrum')
toimage.m程序如下:
function [im,tt] = toimage(A,f,t,splx,sply)
% [im,tt] = TOIMAGE(A,f,t,splx,sply) transforms a spectrum made
% of 1D functions (e.g., output of "spectreh") in an 2D image
%
% inputs : - A : amplitudes of modes (1 mode per row of A)
% - f : instantaneous frequencies
% - t : time instants
% - splx : number of columns of the output im (time resolution).
% If different from length(t), works only for uniform
% sampling.
% - sply : number of rows of the output im (frequency resolution).
% outputs : - im : 2D image of the spectrum
% - tt : time instants in the image
%
% utilisation : [im,tt] = toimage(A,f);[im,tt] = toimage(A,f,t);[im,tt] = toimage(A,f,sply);
% [im,tt] = toimage(A,f,splx,sply);[im,tt] = toimage(A,f,t,splx,sply);
DEFSPL = 400;
if nargin < 3
t = 1:size(A,2);
sply = DEFSPL;
splx = length(t);
else
if length(t) == 1
tp = t;
t = 1:size(A,2);
if nargin < 4
sply = tp;
splx = length(t);
else
if nargin > 4
error('too many arguments')
end
sply = splx;
splx = tp;
end
else
lt = length(t);
if nargin < 5
sply = splx;
splx = lt;
end
if nargin < 4
sply = DEFSPL;
splx = lt;
end
if nargin > 5
error('too many arguments')
end
end
end
end
lt=length(t);
im=[];
im(splx,sply) = 0;
for i=1:size(f,1)
for j = 1:lt
ff=floor(f(i,j)*2*(sply-1))+1;
if ff <= sply % in case f(i,j) > 0.5
im(floor(j*(splx-1)/lt)+1,ff)=im(floor(j*(splx-1)/lt)+1,ff)+A(i,j);
end
end
end
for i = 1:splx
tt(i) = mean(t(floor((i-1)*lt/(splx))+1:floor(i*lt/(splx))));
end
im=fliplr(im)';
if issparse(A) || ~isreal(A) || length(size(A)) > 2
error('A argument must be a real matrix')
end
if issparse(f) || ~isreal(f) || length(size(f)) > 2
error('f argument must be a real matrix')
end
if any(size(f)~=size(A))
error('A and f matrices must have the same size')
end
if issparse(t) || ~isreal(t) || ~isvector(t) || length(t)~=size(A,2)
error('t argument must be a vector and its length must be the number of columns in A and f inputs')
end
if ~isscalar(splx) || ~isreal(splx) || splx ~= floor(splx) || splx <= 0
error('splx argument must be a positive integer')
end
if ~isscalar(sply) || ~isreal(sply) || sply ~= floor(sply) || sply <= 0
error('splx argument must be a positive integer')
end
if any(diff(diff(t))) && splx ~= length(t)
warning('toimage:nonuniformtimeinsants','When splx differs from length(t), the function only works for equally spaced time instants. You may consider reformating your data (using e.g. interpolation) before using toimage.')
end
f = min(f,0.5);
f = max(f,0);
indf = round(2*f*(sply-1)+1);%
indt = repmat(round(linspace(1,length(t),splx)),size(A,1),1);%创建1*size(A,1)大小的矩阵,矩阵中的数据为round(linspace(1,length(t),splx))
im = accumarray([indf(,indt(],A(,[sply,splx]);
indt = indt(1,;
tt = t(indt);
ff = (0:sply-1)*0.5/sply+1/(4*sply);
end
matlab函数accumarray,matlab函数调用问题相关推荐
- matlab函数accumarray,MATLAB常用函数
%%%%%%%%%%%%%%% %MATLAB常用函数 %%%%%%%%%%%%%%% %%%%%%%%%%%%%%%% %特殊矩阵构造函数 %%%%%%%%%%%%%%%% ones 创建一个所有元 ...
- MATLAB函数gensurf,matlab模糊逻辑(二)
6.2 模糊推理结构FIS 6.2.1 不使用数据聚类方法从数据生成FIS结构 函数 genfis1 格式 fismat = genfis1(data) fismat = genfis1(data,n ...
- 双曲线matlab函数拟合,matlab怎么拟合双曲线
储存着各离散点的横坐标和纵坐标,则在 MATLAB 中直接键入命令 cftool(X,Y) 就会弹出 Curve Fitting Tool 的 GUI 界面,点击界面上的 fitting 即可开始曲线 ...
- matlab 函数,matlab 语法1
目录 matlab中fullfile使用 MATLAB中fopen.fprintf函数的用法 Matlab之fgetl函数 Matlab中的Inf和NaN matlab zeros函数的使用 MATL ...
- matlab函数结果,matlab 函数返回多个值--样例
matlab 函数返回多个值--样例 发布时间:2018-02-14 19:52, 浏览次数:2062 , 标签: matlab 目录 一.matlab的函数文件返回多个值写法 二.简单的例子 三. ...
- matlab函数图像代码,matlab图像函数大全
图像增强 1. 直方图均衡化的 Matlab 实现 1.1 imhist 函数 功能:计算和显示图像的色彩直方图 格式:imhist(I,n) imhist(X,map) 说明:imhist(I,n) ...
- MATLAB函数gensurf,MATLAB模糊逻辑工具箱函数.ppt
1 MATLAB模糊逻辑工具箱简介 2 利用模糊逻辑工具箱建立模糊推理系统 3 MATLAB模糊逻辑工具箱的图形用户界面 4 基于Simulink的模糊逻辑的系统模块 5.2.5 模糊推理计算与去模糊 ...
- python中matlab函数图像处理,MATLAB图像处理--同态滤波(代码及示例)
一幅图像f(x,y)能够用它的入射光分量和反射光分量来表示,其关系式如下 f(x,y)=i(x,y)r(x,y) 图像f(x,y)是由光源产生的照度场i(x,y)和目标的反射系数场r(x,y)的共同作 ...
- matlab函数anova,MATLAB进行单因素方差分析-ANOVA
<MATLAB进行单因素方差分析-ANOVA>由会员分享,可在线阅读,更多相关<MATLAB进行单因素方差分析-ANOVA(5页珍藏版)>请在人人文库网上搜索. 1.MATLA ...
- matlab 函数 平移,MATLAB图线先下平移
平移有哪些性质? 平移后的线段与原线段平行(或在同一直线上)且相等其性质相当于平行四边形的性质. 函数的平移规律 左加右减在x上上加下减在y上 平移一次函数问题 解题思路:根据一次函数平移的性质解答解 ...
最新文章
- linux进入文件系统命令,卸载正在被访问的文件系统 - fuser命令
- 蓝桥杯python青少年_蓝桥杯大赛青少年组省赛结果公布
- 用matlab绘制抛物线y的x平方,我刚刚学习MATLAB,想画一下(x^2+y^2-1)^3=x^2*y^3这个曲线的图像,该怎么画呢,谢谢大家了。...
- OpenCV扫描图像对象的实例(附完整代码)
- 大数据背后是个万亿市场
- java hanoi塔问题_java 解决汉诺塔问题
- Linux 信号signal处理函数
- C++中类的拷贝控制
- JPG,动态GIF,BMP一些常用解决办法
- 如何解决CAN FD与CAN网络共存问题
- win10计算机系统优化设置,win10最详细优化设置 win10全面优化教程
- [译]关于Android图形系统一些事实真相
- 怎样把照片中的头像扶正_礼仪|职场人士微信头像怎么选才得体?
- 阿里巴巴二重身ABBC Coin虚涨逾100%
- Python实现BOA蝴蝶优化算法优化支持向量机回归模型(SVR算法)项目实战
- 数据包从物理网卡流经 Open vSwitch 进入 OpenStack 云主机的流程
- VMware下Linux与Windows共享文件
- 如何写专业的数据分析报告
- 项目里的UT越来越慢,怎么办?
- matlab中alw,MATLAB环境下遗传算法优化工具箱的应用_刘万林
热门文章
- 项目配置文件----.eslintignore,eslint在做风格检查的时候忽略 dist 和 vender(第三方库) 不去检查。
- Milton 1.5.1发布,开源服务器端类库
- 万字总结,行业分析到底应该怎么做!
- 2021年中国消费金融行业贷款情况及发展趋势分析:互联网消费金融放款规模达到20.2万亿[图]
- 桌面运维常见问题解决办法③
- excel插件方格格子
- django improperly configured
- 计算机网络期末实验考试题目+总结(用的是CISCO软件~~)
- 高数函数的连续性与间断点
- 默认关闭idea2020的注释doc的rendered view模式