Effacer les filtres
Effacer les filtres

hello, how can I resolve this?

2 vues (au cours des 30 derniers jours)
Enrico Azzini
Enrico Azzini le 9 Nov 2019
Commenté : KALYAN ACHARJYA le 10 Nov 2019
2 1 2 1
2 2 4 1
2 3 8 1
2 4 16 1
2 5 32 1
2 6 64 1
2 7 128 1
2 8 256 1
2 9 512 1
2 10 1024 NaN
2 11 2048 NaN
2 12 4096 NaN
hi, suppose that I have the matrix below and (where NaN is a string) how can I calculate the number of NaNs of the fourth column of matrix and assign it to a variable called “N_NAN”? Thank you
  1 commentaire
darova
darova le 9 Nov 2019
Replace NaN with 1

Connectez-vous pour commenter.

Réponse acceptée

KALYAN ACHARJYA
KALYAN ACHARJYA le 9 Nov 2019
Modifié(e) : KALYAN ACHARJYA le 10 Nov 2019
data=[2 1 2 1
2 2 4 1
2 3 8 1
2 4 16 1
2 5 32 1
2 6 64 1
2 7 128 1
2 8 256 1
2 9 512 1
2 10 1024 NaN
2 11 2048 NaN
2 12 4096 NaN];
NaN_sum=sum(isnan(data(:,4))); %Its gives the sum of NaN
% Find the r and c of NaN
[r c]=find(isnan(data));
Now replace those r,c with new strings N_NAN, for that you may require to convert the array to cell array, right?
  3 commentaires
darova
darova le 9 Nov 2019
I agree. THere is no need fo such overcomplications
KALYAN ACHARJYA
KALYAN ACHARJYA le 10 Nov 2019
Yes, its my bad. Thanks for pointing it out @Walter Sir
Thanks @Darova

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by