load('matlab_f.mat')
f
f = 4x2 cell array
{'a'} {'1'} {'a'} {'1'} {'c'} {'2'} {'c'} {'1'}
i want to find row equal
f(1.:) and f(2,:) are equal
f(3.:) and f(4,:) are not equal

 Akzeptierte Antwort

Matt J
Matt J am 13 Okt. 2024

0 Stimmen

>> findgroups(f(:,1),f(:,2))
ans =
1
1
3
2

4 Kommentare

shamal
shamal am 13 Okt. 2024
ok but see this example:
findgroups(DD(:,1),DD(:,11))
Error using matlab.internal.math.grp2idx (line 158)
A grouping variable of class 'cell' is not supported.
Matt J
Matt J am 13 Okt. 2024
Bearbeitet: Matt J am 13 Okt. 2024
load('matlab_DD.mat')
findgroups(cell2table(DD(:,[1,11])))
ans = 103×1
28 43 49 96 51 16 18 15 17 20
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
shamal
shamal am 13 Okt. 2024
thank but if i want to delete duplicate..can i do it?
can I search for the same pairs and delete one of these or is there a faster method
Matt J
Matt J am 13 Okt. 2024
Bearbeitet: Matt J am 13 Okt. 2024
I demonstrated how to do that in my other answer.
Ultimately, you should probably convert your data and leave it in table form. The things you are asking are very readily done with the data in that form.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (2)

Matt J
Matt J am 13 Okt. 2024
Bearbeitet: Matt J am 13 Okt. 2024

0 Stimmen

load('matlab_f.mat')
table2cell(unique(cell2table(f),'rows'))
ans = 3x2 cell array
{'a'} {'1'} {'c'} {'1'} {'c'} {'2'}
Sameer
Sameer am 13 Okt. 2024
Bearbeitet: Sameer am 13 Okt. 2024

0 Stimmen

Hi Luca
To compare rows of a cell array and determine if they are equal, you can use the "isequal" function.
Here's how you can do it:
load('matlab_f.mat')
% Check if the first and second rows are equal
if isequal(f(1,:), f(2,:))
disp('f(1,:) and f(2,:) are equal');
else
disp('f(1,:) and f(2,:) are not equal');
end
f(1,:) and f(2,:) are equal
% Check if the third and fourth rows are equal
if isequal(f(3,:), f(4,:))
disp('f(3,:) and f(4,:) are equal');
else
disp('f(3,:) and f(4,:) are not equal');
end
f(3,:) and f(4,:) are not equal
Please refer to the below MathWorks documentation link:
Hope this helps!

Kategorien

Mehr zu Data Type Identification finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 13 Okt. 2024

Bearbeitet:

am 13 Okt. 2024

Community Treasure Hunt

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

Start Hunting!

Translated by