Is there a way to remove double from the variable?

5 views (last 30 days)
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 Comments
Lester Lim
Lester Lim on 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 on 24 Jan 2013
The mtimes problem is being discussed in another earlier thread.

Sign in to comment.

Accepted Answer

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

More Answers (0)

Categories

Find more on Statistics and Machine Learning Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!