首页 > 解决方案 > 绘制信号的导数

问题描述

我的编码遇到问题。我在一个图中有多个图。我正确地得到了我的所有图,但不幸的是,导数图在图中甚至都看不到。谁能帮忙..提前谢谢

close all
clear all
clc
load('2019-01-31-structTFMRI-Proband04-Ivan.mat')

fs=structTFMRI.SigInfo.fs; %Sampling frequency in Hz
%PlotLead = 10;
%ECG lead to plot (only used for 12-lead ECG)

%% 12-lead ECG (Outside and Inside MRI)
ECGOutSingle = structTFMRI.ECGMRI.ECG12OutSingle; %820 Samples per beat (~800ms), 120 beats, 12 leads
ECGInSingle = structTFMRI.ECGMRI.ECG12InSingle; %820 Samples per beat (~800ms), 182 beats, 12 leads

%Plot the data
figure; 
hold on
for PlotLead=4:4
    t=(0:1:length(ECGOutSingle(:,1,PlotLead))-1)/fs; %Time vector for plot to have x-axis in seconds
    %plot(t,ECGOutSingle(:,1,PlotLead))
    %plot(t,ECGInSingle(:,1,PlotLead))
    plot(t,ECGInSingle(:,1,PlotLead)-ECGOutSingle(:,1,PlotLead))  %MHD signal

    MHD = ECGInSingle(:,1,PlotLead)-ECGOutSingle(:,1,PlotLead);
    x = 1:length(ECGInSingle);
    [Zi,Zi_idx,Xi,Xi_idx,Bi,Bi_idx] = getZXB(MHD);  
    y = diff(MHD);
    z = diff(x);
    plot(z,y); 
    plot(x,MHD);
    plot(x(Bi),MHD(Bi),'r*');
    plot(x(Xi),MHD(Xi),'g*');
    plot(Zi_idx,Zi,'b*');
end

标签: matlabderivative

解决方案


您正在绘制 的导数MHD与 的导数x

y = diff(MHD);
z = diff(x);
plot(z,y); 

相反,绘制MHD反对的导数x

y = diff(MHD);
plot(x,y);

diff(x)是一个具有所有相同值的数组。因此,您的所有值y都绘制在沿 x 轴的同一位置。


推荐阅读