How to check repeated multiple cell array data for one decimal value?

Checking the first two set of data in individula cell of 'A' with its 1st decimal value only but could not implement the logical statement with the converted data.
load("A.mat");
count = 0;
for i= 1:3
%B{1,i} = A{1,i}';
C{1,i} = sprintf('%10.1f',A{1,i}); % converted to the values
B{1,i} = reshape(sscanf(sprintf('%10.1f*', A{1,i}),'%f*'),[],1); % converted into single column (1x3)
% if all((B(1,1) == B(i,1)) && (B(2,1)==B(1,i)) % invalid
% count = count+1;
% else
% fprintf("does not matched with any data")
% end
end

6 Comments

Do you want compare the first digits of the values to the first digit of the 1st element in the row?
A=load("A.mat").A;
B=A{1,1}
B = 2×766
29.6042 29.5127 29.4189 29.3227 29.2239 29.1239 29.0239 28.9239 28.8239 28.7239 28.6239 28.5239 28.4239 28.3239 28.2239 28.1239 28.0239 27.9239 27.8239 27.7239 27.6239 27.5239 27.4239 27.3239 27.2239 27.1239 27.0239 26.9239 26.8239 26.7239 -242.4968 -242.5968 -242.6968 -242.7968 -242.8968 -242.9955 -243.0917 -243.1849 -243.2752 -243.3628 -243.4477 -243.5300 -243.6098 -243.6873 -243.7624 -243.8352 -243.9058 -243.9741 -244.0400 -244.1038 -244.1655 -244.2251 -244.2829 -244.3387 -244.3927 -244.4449 -244.4954 -244.5440 -244.5908 -244.6357
base=10.^floor(log10(abs(B)));
y=fix(B./base)
y = 2×766
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2 -2
all(diff(y,1,2)==0,'all')
ans = logical
0
Thank you Dyuman for you response,
Actually I want check wheatehr the set of values i.e. 1st row 1st col with 2nd row 1st col of A{1,1} is repeated on this cell or not.
In a given data for cell A{1,1} I need to check for (29.6, -242.4) and same process repeat for other cell A{1,2} and A{1,3}
So you want to see, if there is the values (rounded to 1 point after decimal) are repeating or not, in their respective row?
And what if they are repeating? What would you want to do afterwards? Find the indices where the repeatition occurs?
These point are the coordiate of the curve lines in terms of x,y. I want to check wheather the line is repeated at its original coordinate or not? Here each cell represent a curve line i.e. A{1,i} and each the point represents its coordinate values x and y i.e. xValue = A(1,1) and yValue = A(2,1).
A=load("A.mat").A
A = 1×3 cell array
{2×766 double} {2×766 double} {2×995 double}
for idx=1:numel(A)
%rounding upto 1 point after decimal
B=round(A{idx},1);
%checking if the line is repeated or not
fprintf('Checking for repetition in row1 of A{1,%d}',idx)
row1=any(abs(B(1,2:end)-B(1,1))<1e-1,2)
fprintf('Checking for repetition in row2 of A{1,%d}',idx)
row2=any(abs(B(2,2:end)-B(2,1))<1e-1,2)
%use find() to obtain the indices where the repetition occurs
end
Checking for repetition in row1 of A{1,1}
row1 = logical
1
Checking for repetition in row2 of A{1,1}
row2 = logical
1
Checking for repetition in row1 of A{1,2}
row1 = logical
1
Checking for repetition in row2 of A{1,2}
row2 = logical
1
Checking for repetition in row1 of A{1,3}
row1 = logical
0
Checking for repetition in row2 of A{1,3}
row2 = logical
1

Sign in to comment.

Answers (0)

Categories

Products

Release

R2022b

Asked:

on 14 Jan 2023

Commented:

on 16 Jan 2023

Community Treasure Hunt

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

Start Hunting!