Is there a way to remove double from the variable?

조회 수: 5 (최근 30일)
Lester Lim
Lester Lim 2013년 1월 24일
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
Lester Lim
Lester Lim 2013년 1월 24일
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 2013년 1월 24일
The mtimes problem is being discussed in another earlier thread.

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2013년 1월 24일
To convert an array such as labelImage from being double to being uint8, use
newArray = uint8(labelImage);

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by