信号分解算法 | Matlab基于一维小波分解算法(Wavelet Decomposition)的信号分解算法

该文章介绍了如何使用Matlab进行一维小波分解算法(WaveletDecomposition)来分解信号。通过示例代码展示了如何计算数据在向量方向上的投影,并进行数据可视化,将2D数据降维至1D的过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


效果一览

1

文章概述

信号分解算法 | Matlab基于一维小波分解算法(Wavelet Decomposition)的信号分解算法

部分源码

%--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
bound = 5;                      % Display boudary x[-5 5] y[-5 5]
theta = linspace(0,pi,60);%0:0.02:pi;              % The theta of vector / line
[~,n] = size(theta);            % Get the size of theta
vec = [cos(theta); sin(theta)]; % Generate vector for theta
XRange = [-bound;bound];        % X range
YRangeSet = [XRange(1).*tan(theta); XRange(2).*tan(theta)]; % Y range set 
dist = vec'*data;               % Dot product of vector and data to obtain the length on vector's direction
%--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
% Draw
figure(1);
axis([XRange',XRange']);
hold on;
%--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
%pic_num = 1;
for i = 1:n
    cla;                            % Clear figure
    YRange = YRangeSet(:,i);        % Obtain the current YRange
    the = theta(i);                 % Obtain the current theta
    coordinate = [dist(i,:).*cos(the); dist(i,:).*sin(the)];    % Obtain the coordinate of the projection point
    plot(data(1,:),data(2,:),'b.','MarkerSize',10);             % Plot original data
    drawLine(XRange, YRange, the);                              % Draw feature %--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    plot(coordinate(1,:),coordinate(2,:),'r.','MarkerSize',10); % Draw projection points
    X = [data(1,:);coordinate(1,:)]; 
    Y =[data(2,:); coordinate(2,:)];
    line(X,Y,'color','r');                                      % connect the original data to projection points
    gca = legend('original data','feature plane', 'projection data'); % Add %--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    % Add labels and titles
    xlabel('x');    ylabel('y');    title('Dimension Reduction (from 2-dim to 1-dim)');
    drawnow();                      % Display
%--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    % Just for gif generation
    % F=getframe(gcf);
%--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    % [I,map]=rgb2ind(I,256);
    % if pic_num == 1
    %     imwrite(I,map,'test.gif','gif','Loopcount',inf,'DelayTime',0.2);
    % else
    %     imwrite(I,map,'test.gif','gif','WriteMode','append','DelayTime',0.2);
    % end
    %pic_num = pic_num + 1;
%--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
end
hold off
%--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

function drawLine(XRange,YRange,theta)
    if(YRange(1)<XRange(1) || YRange(1) > XRange(2))
%--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
            YRange = XRange;
            XRange = YRange./tan(theta);
%--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
            YRange = fliplr(XRange);
            XRange = YRange./tan(theta);
        end
    end
    line([XRange(1),XRange(2)],[YRange(1), YRange(2)],'color','k');
end
%--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------













参考资料

[1] https://blog.youkuaiyun.com/m0_57362105/article/details/130383523?spm=1001.2014.3001.5502

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

前程算法屋

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值