声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1574|回复: 5

[综合讨论] 两段程序如何提高速度

[复制链接]
发表于 2009-2-11 10:09 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
这两天看了好多有关提高matlab运算速度的信息,也知道应该尽量用矩阵运算来代替循环
可本人有些愚钝,写了两段程序,用了大量的循环,也不知道应该怎样用矩阵运算来改写,
希望哪位大侠能帮我分析或改写下,不胜感激!!!
回复
分享到:

使用道具 举报

 楼主| 发表于 2009-2-11 10:10 | 显示全部楼层
function C_I=correlation_integral(X,M,r,qs)
%the function is used to calculate correlation integral
%C_I:the value of the correlation integral
%X:the reconstituted state space, is a m*M matrix
%m:the embedding demention
%M:M is the number of embedded points in m-dimensional space
%r:the radius of the Heaviside function,sigma/2<r<2sigma
%calculate the sum of all the values of Heaviside
%skyhawk
sum_H=zeros(1,M);
for i=1:M
    for j=1:M
        if j==i
            continue;
        end
        d=norm((X(:,i)-X(:,j)),inf);%calculat the distances of each two points in matris M with sup-norm
        sita=heaviside(r-d);%calculate the value of the heaviside function
        sum_H(i)=sum_H(i)+sita;
    end
    sum_H(i)=sum_H(i)^qs;
end
C_I=sum(sum_H);%the value of correlation integral


function X=reconstitution(data,N,m,tau)
%该函数用来重构相空间
% m 为嵌入空间维数
% tau 为时间延迟
% data 为输入时间序列
% N 为时间序列长度
% X 为输出,是m*n 维矩阵
M=N-(m-1)*tau;%相空间中点的个数
for j=1:M %相空间重构
    for i=1:m
        X(i,j)=data((i-1)*tau+j);
    end
end
 楼主| 发表于 2009-2-11 10:15 | 显示全部楼层
还有个问题就是我想把其中一个函数编译成dll文件,然后在程序中调用它,编译通过了,也得到了dll文件,然后我把dll文件拷贝至缺省工作目录work下,可是在matlab程序中调用它的时候出错了,请高手们帮我分析下是什么问题,谢谢!!

r=test_1_0(1,10);
这个是调用dll文件,可是提示
Mex file entry point is missing.  Please check the (case-sensitive)
spelling of mexFunction (for C MEX-files), or the (case-insensitive)
spelling of MEXFUNCTION (for FORTRAN MEX-files).
??? Invalid MEX-file 'D:\MATLAB71\work\test_1_0.dll': 找不到指定的模块。


r=showsin(1,10);
这个是调用m文件,通过没问题
发表于 2009-2-11 16:29 | 显示全部楼层
同样的困惑,关注中。。
发表于 2009-2-11 16:46 | 显示全部楼层

回复 沙发 du219 的帖子

LZ原始公式为何? 直接用公式写或许比看LZ的程式快!
发表于 2009-2-14 10:30 | 显示全部楼层

回复 地板 mathes 的帖子

lz的程序:loveliness: 想学习下呢。。。。:loveliness: :loveliness:
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-9-22 21:20 , Processed in 0.062118 second(s), 19 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表