Comparing array with any element of the array
정보
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
이전 댓글 표시
Hello All.
I have vector named classes
classes =
1
2
I need to compare all classes element with
D = dataset(dataset(:,p)==X,:);
Briefly equation above should compareing with all classes elements, for my example X should be 1 or 2
X can be any element of classes vector, in my code i compare p th element of the dataset array with X , X is one of the elemeny of classes vector.
I just create a example classes matrix it can be any array.
댓글 수: 4
Guillaume
2019년 12월 18일
Your question is very unclear. All we know is that you have two things. One looks like it is a vector called classes, the other is a 2D matrix called D. Incidentally all the values in column p of D are all equal to X, but it doesn't sound like it's relevant.
It's unclear what 'compare' means in this context, so please provide an example of all inputs and desired output.
betul uslu
2019년 12월 18일
편집: betul uslu
2019년 12월 18일
Guillaume
2019년 12월 18일
As I wrote please provide an example of all inputs and desired output.
betul uslu
2019년 12월 18일
편집: betul uslu
2019년 12월 18일
답변 (1개)
Guillaume
2019년 12월 18일
Ok, now I understand what you want to do.
Note that datasets have been deprecated for a while and it's recommended you use tables instead. I'm not familiar with datasets and I don't have the toolbox so the following is for tables. You can easily transform your dataset into a table with dataset2table.
First, I'll note that typically splitting a table into several tables is rarely useful. Matlab has plenty of functions that allows you to perform group statistics according to a particular column. These work on a single table. See groupsummary, grouptransform, groupfilter, etc.
If you really want to split the table into multiple tables:
g = findgroup(yourtable(:, p));
splittables = splitapply(@(rows) {yourtable(rows, :)}, (1:height(yourtable)).', g); %split table into cell array of tables
댓글 수: 2
betul uslu
2019년 12월 18일
Guillaume
2019년 12월 18일
a) Go back to your lecturer and tell him to move on with the time. datasets have long been deprecated and don't have as many useful features as tables.
b) You can trivially convert tables back to dataset with table2dataset
이 질문은 마감되었습니다.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


