how to put two doubles coulmns and third is strings in uitable GUI?
3 views (last 30 days)
Show older comments
I am trying to get the results of my predication to be in two columns where zeros and ones while the third column give me the closest neighbours based on KNN using the Names
i tried the following:
resultdata= [Double' doubleout KNnames];
columnformat = {'numeric','numeric','char'};
set(handles.uitable2, 'Data',resultdata , 'ColumnFormat',columnformat);
but not working I want to be like the following knowing that I loaded the first columns from files and the third two from another excel file
Column1 cloumn2 column 3
1 1 y1
0 1 y3
2 Comments
Andreas Donauer
on 28 Jun 2016
Edited: Andreas Donauer
on 28 Jun 2016
Not working = you get an error message?
Also, could you clarify what the input data ("Double", "doubleout" "KNnames"). I'd guess you mixed something up trying create "resultdata" and your dimensions do not agree.
That said: "resultdata" is a cell array? (If it is not, try "{}" instead of "[]" for "resultdata")
Accepted Answer
Walter Roberson
on 29 Jun 2016
Edited: Walter Roberson
on 29 Jun 2016
'Data', [num2cell(k(:)), num2cell(d(:)), knames(:)]
provided your knames is a cell array of strings.
3 Comments
Walter Roberson
on 29 Jun 2016
You had {k,d,knames} . That means to create a 1 x 3 cell array in which the first element is "everything in k", the second element is "everything in d" and the third element is "everything in knames". But that is not what you want: you want a (something by 3) cell array in which each element of the cell array has exactly 1 numeric value (first two columns) or exactly 1 string (third column). So you need to convert the numeric vectors into cell arrays with one numeric value per array element, which is exactly the purpose of num2cell. The (:) part ensures that you get a column vector of results. When you have the cell array made by converting k, and the cell array made by converting d, and the existing cell array of strings in knames, then you can put those together in a (something by 3) cell array by using the horzcat() operation, the short form of which is []
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!