hi sir,i have cell of 10*10 cell which look like below double <5x10 double> <5x10 double> <5x10 double> <5x10 double> <5x10 double> <5x10 double> <5x10 double> <5x10 double>
i have to find in which 5x10 double NaN is present

1 Kommentar

Jan
Jan am 7 Mai 2015
The description of the data is not clear. Please post some code, which create a relevant set of test data - with small arrays.

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 7 Mai 2015

0 Stimmen

A={[1 nan 2] [1 3 5] [nan nan 7] [9 7 2]}
out=cellfun(@(x) any(any(isnan(x))),A)

2 Kommentare

POOJA KJ
POOJA KJ am 7 Mai 2015
thank you so much
Stephen23
Stephen23 am 7 Mai 2015
Bearbeitet: Stephen23 am 7 Mai 2015
A more general solution could be independent of the array dimensions:
out = cellfun(@(x) any(isnan(x(:))), A);

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Jan
Jan am 7 Mai 2015

0 Stimmen

Perhaps:
x = {1:5, 2:6, [3,4,NaN,6,7]};
hasNaN = false(size(x));
for ix = 1:numel(x)
hasNaN(ix) = any(isnan(x{ix}));
end
A CELLFUN could do this also, but a loop is easier to understand and fast to write. Please explain at first if my guess matches your data.

1 Kommentar

POOJA KJ
POOJA KJ am 7 Mai 2015
its great answer...bt i m getting error as In an assignment A(:) = B, the number of elements in A and B must be the same. In the cell that u ve given, has one row in each block.but in the cell which i ve has 5*10 elements in each block.this may be the reason....could u please resolve

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Matrices and Arrays finden Sie in Hilfe-Center und File Exchange

Tags

Noch keine Tags eingegeben.

Community Treasure Hunt

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

Start Hunting!

Translated by