Is there a way to remove double from the variable?

6 visualizzazioni (ultimi 30 giorni)
In the workspace, my variable is: lableimage < 359x476x3 double > Whenever I reshape it into a single column, the result is not 170884x1 but 512652x1. Also, because its double, the LDA is not working. Any suggestions?
  8 Commenti
Lester Lim
Lester Lim il 24 Gen 2013
Line error : projectedSamples = samples * vectors;
---------------------------------------------------
Error:
Error using * MTIMES is not fully supported for integer classes. At least one input must be scalar. To compute elementwise TIMES, use TIMES (.*) instead.
Error in LDA/Transform (line 60) projectedSamples = samples * vectors;
---------------------------------------------------------------------
Input: data = importdata('LDA data.mat')
features=data(:,1:end-1); %split data without labels
lable=data(:,end); %get the labels
trainSamples = features;%training samples
trainClasses = lable;%training labels
I2 = reshape(I,[],1);
testSamples = I2;%test samples
lableimage = reshape(handles.lableimage,[],1);
testClasses = lableimage;%test labels
mLDA = LDA(trainSamples, trainClasses);
mLDA.Compute();
transformedTrainSamples = mLDA.Transform(trainSamples, 1);
transformedTestSamples = mLDA.Transform(testSamples, 1);
calculatedClases = knnclassify(transformedTestSamples, transformedTrainSamples, trainClasses);
simmilarity = [];
for i = 1 : 1 : length(testClasses)
similarity(i) = ( testClasses{i} == calculatedClases{i} );
end
accuracy = sum(similarity) / length(testClasses);
fprintf('Testing: Accuracy is: %f %%\n', accuracy*100);
guidata(hObject, handles);
Walter Roberson
Walter Roberson il 24 Gen 2013
The mtimes problem is being discussed in another earlier thread.

Accedi per commentare.

Risposta accettata

Walter Roberson
Walter Roberson il 24 Gen 2013
To convert an array such as labelImage from being double to being uint8, use
newArray = uint8(labelImage);

Più risposte (0)

Categorie

Scopri di più su Statistics and Machine Learning Toolbox in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by