Is there a way to remove double from the variable?

5 vues (au cours des 30 derniers jours)
Lester Lim
Lester Lim le 24 Jan 2013
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 commentaires
Lester Lim
Lester Lim le 24 Jan 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 le 24 Jan 2013
The mtimes problem is being discussed in another earlier thread.

Connectez-vous pour commenter.

Réponse acceptée

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

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by