필터 지우기
필터 지우기

hello, how can I resolve this?

조회 수: 2 (최근 30일)
Enrico Azzini
Enrico Azzini 2019년 11월 9일
댓글: KALYAN ACHARJYA 2019년 11월 10일
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
darova
darova 2019년 11월 9일
Replace NaN with 1

댓글을 달려면 로그인하십시오.

채택된 답변

KALYAN ACHARJYA
KALYAN ACHARJYA 2019년 11월 9일
편집: KALYAN ACHARJYA 2019년 11월 10일
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
darova
darova 2019년 11월 9일
I agree. THere is no need fo such overcomplications
KALYAN ACHARJYA
KALYAN ACHARJYA 2019년 11월 10일
Yes, its my bad. Thanks for pointing it out @Walter Sir
Thanks @Darova

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by