Matlab错误:TRAINING中每个组的协方差矩阵必须是正定的

时间:2013-03-15 10:17:27

标签: matlab signal-processing classification quantization

我目前正在研究分类过程中采样率和量化对肿瘤信号的影响。我得到错误'培训的合并协方差矩阵必须是 肯定的。'仅当我尝试对量化信号(8位)进行分类时。如果quantzatoin设置为> 8位,则代码运行完美!

我有点困惑,并希望任何人可能有任何帮助。

我的代码如下:

    clear all;
    close all;
    clc;

    load('AllSignalsModified.mat')

    % =================================%
    % PCA - Feature Extraction
    % =================================%
    [cl, pcaAll]= princomp(allSignals);
    bestFeatures = pcaAll(:,1:100);

    %==============================%
    % Decimate allSignals
    %==============================%

    nsamp = 100;
    fs1 = 50e9;
    N = 2;
    fs2 = fs1/N;
    x = allSignals;

    % iterate thru each tumour signal

    for i = 1:960,
        oneRow= allSignals(i,:);
        downSampleRow(i,:) = oneRow(1:N:end);
    end;

    oneSampleRow = downSampleRow(1,:);

    %==========================================%
    % Quantisation 
    %==========================================%

    nbits = 8;

    for i = 1:960,
        x = downSampleRow(i,:);
        x2 = x / max(abs(x));
        x3= x2 .* 2^(nbits-1)-1;
        quantisedSig(i,:) = round(squeeze(x3));
    end;

    % =================================%
    % LDA Classification 
    % =================================%

    typeOfTumour(typeOfTumour<=2) = 0;
    typeOfTumour(typeOfTumour>=3) = 1;

    testSetResult = classify(quantisedSig,quantisedSig,typeOfTumour,'linear');
    testSetResult1 = classify(quantisedSig,quantisedSig,typeOfTumour,'quadratic');

    count = 0;
    for i = 1:960,
        if(testSetResult(i) == typeOfTumour(i))
            count = count + 1;
        end;
    end;

    count1 = 0;
    for i = 1:960,
        if(testSetResult1(i) == typeOfTumour(i))
            count1 = count1 + 1;
        end;
    end;

    percentageCorrect = (count/960)*100;
    percentageCorrect1 = (count1/960)*100;
    display(percentageCorrect);
    display(percentageCorrect1);

0 个答案:

没有答案