MATLAB Answers

0

How to count average number of occurance of data and Nan from text file.

Prashant Dwivedi さんによって質問されました 2018 年 11 月 15 日
最新アクティビティ Prashant Dwivedi さんによって コメントされました 2018 年 11 月 15 日
Dear all,
I'm new to Matlab
I have a text data file like :
# "Frame" "CenterofMass"
0 [5.35542667 7.49759667 6.42651167]
1 [5.36150333 7.49310833 6.44564167]
2 Nan
3 Nan
4 Nan
5 [42.3471765 12.4554735 12.32290767]
6 [22.016623 13.46475567 21.90701423]
7 [32.80792167 13.49493133 21.81519458]
8 Nan
9 [22.05034433 13.24664267 32.74229167]
I wanted to count average occurance of data(some numbers) like: (2+3+1)"sum of data row"/3 '''occurance of data row 3 times' will give average =2
same for Nan : (3+1)/2=2 .
How to do that in matlab.
Any help will be appriciated.
thank you in advance

  0 件のコメント

サインイン to comment.

1 件の回答

回答者: Arunkumar M 2018 年 11 月 15 日
 採用された回答

You can use xlsread function if you have the data in the form of excel or csv.
Let us take a as the variable holding data.
[m n] = size(a);
num_rows_NaN = 0;
num_rows_number = 0;
for i = 1:m
if (sum(isnan(a(i,:)))) == 0
num_rows_NaN = num_rows_NaN + 1;
else
num_rows_number = num_rows_number + 1;
end
end

  1 件のコメント

Prashant Dwivedi 2018 年 11 月 15 日
Thank you so much for help.
It's working perfactly for counting Nan and data . But i have to find average occurance of Nan and data. as I asked above.
Is it possible to find.
thank you

サインイン to comment.



Translated by