How to deal with NaN statistical analysis?

First block
[cmin, indice_min]=min(IRR(:,4));
min_dia=IRR(indice_min, 1:3);
disp(min_dia)
Second block
[cmean, indice_mean]=mean(IRR(:,4), ('omitnan')); %
mean_dia=IRR(indice_mean, 2:3);
disp(mean_dia)
Dear all,
I have been analysing a dataset, whereas I have noticed that for some statistical operations such as "min", "max", and also "mode", there are not problems if datastes contains blank spaces ("NaN"), nonetheless, for "median" as well as "mean" the statistical MATLAB functions present some issues, even if I include in the code 'omitnan'. The structure portrayed at "First Block" works correctly, nevertheless, "Second block" does not work properly presenting some issues. Would you helping me with this?
I hope you can help me to cope with this problem.
Sincerely,

2 Kommentare

Adam
Adam am 2 Mär. 2020
You didn't tell us what the issues are and we don't have the data to run your code.
Tony Castillo
Tony Castillo am 2 Mär. 2020
You are rigth

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Jonas Allgeier
Jonas Allgeier am 2 Mär. 2020

0 Stimmen

Mean only gives you a single output argument, the mean value; so requesting a second output argument will not work.

6 Kommentare

Tony Castillo
Tony Castillo am 2 Mär. 2020
"min", "mode", etc give a single value as well, is not it?
Jonas Allgeier
Jonas Allgeier am 2 Mär. 2020
no, min() has a second output argument, which gives you the index of the minimum value. Check help min and help mean.
Tony Castillo
Tony Castillo am 2 Mär. 2020
The problem is this if I do not include de index I get a value, but as I need the index it returns to me a error:
mean(IRR(:,4),'omitnan')
ans =
3333.20
>> [cmen, indi_mean]=mean(IRR(:,4),'omitnan')
Error using mean
Too many output arguments.
Adam
Adam am 2 Mär. 2020
How can you 'need the index' for a mean? It has no index, it's just an average.
Tony Castillo
Tony Castillo am 2 Mär. 2020
You have the reason, sorry for it.
However, as I need a day for my analysis with mean value. I prepared this script in order to find that day. In this way I get one day with the exactly characteristics from a mean value.
cmean=mean(IRR(:,4), ('omitnan'));
[row,col]=find(IRR>=(cmean-1)&IRR<=(cmean+1), 1);
mean_dia=IRR(row, 1:3);
disp(mean_dia)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte

Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by