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);
  1 件のコメント
Lester Lim
Lester Lim 2013 年 1 月 24 日
Im working on it...

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by