ttest error - undefined variable - error nanmean nanvar etc.

조회 수: 7 (최근 30일)
Ilaria Sani
Ilaria Sani 2020년 8월 9일
댓글: Pengyuan Sun 2023년 4월 13일
Dear All,
I am trying to perform a simple statistics:
two vectors and a ttest or ttest2.
I have done that before, but now I am getting an error. Ranksum works instead.
e.g.1) ttest(x)
Undefined variable "coder" or class "coder.internal.scalarEg".
Error in nan_sum_or_mean (line 11)
XZERO = coder.internal.scalarEg(x);
Error in nanmean (line 7)
y = nan_sum_or_mean('mean',varargin{:});
Error in ttest (line 131)
xmean = nanmean(x,dim);
e.g.2) ttest2(x,y)
Undefined function or variable 'eml_is_const'.
Error in nanvar (line 29)
coder.internal.assert(eml_is_const(dim), ...
Error in ttest2 (line 169)
s2x = nanvar(x,[],dim);
I found in the forum several suggestions like:
-make sure you have statistics toolbox. I have statistics and machine learning and I re-installed everything from scratch, just to be extra sure.
-make sure you are using "official" functions and I do.
I have no clue as to why it is not working.
I am using matlab 2016b
Can anyone help me figure it out?
Thank you in advance,
Ilaria
  댓글 수: 2
the cyclist
the cyclist 2020년 8월 9일
Make it easy for us to help you. Attach your code (in *.m file), and your data (in a *.mat), using the INSERT function (the one that looks like a paper clip) in the toolbar, so that we can reproduce your problem.
Ilaria Sani
Ilaria Sani 2020년 8월 10일
Hi cyclist,
there is no code involved here.
I am typing ttest in the command window and making up a couple of vectors.
Does this help?
Ilaria

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

채택된 답변

Walter Roberson
Walter Roberson 2020년 8월 9일
Error in nanvar (line 29)
coder.internal.assert(eml_is_const(dim), ...
In R2016b, the release you are using, nanvar has 30 lines of comments and then one line of narginchk and then one line of calling var() with 'omitnan' . There is no coder.internal.assert call in it.
... Not unless one of the following is true:
  1. You are attempting to compile the code using MATLAB Coder which would be important to know for this purpose; OR
  2. You are calling nanmean in Simulink within a MATLAB Function Block, and you have Acceleration turned on or Rapid Acceleration turned on; OR
  3. You have found the files intended to be used for code replacement for nanvar when using MATLAB Coder (or Simulink Coder), and you have put those directories onto your MATLAB Path earlier than the correct directories. If so then restoredefaultpath; rehash toolboxcache;
  댓글 수: 7
Pengyuan Sun
Pengyuan Sun 2023년 4월 13일
Hi Walter,
Thanks for your reply!
I experimented with restoredefaultpath and rehash toolboxcache, but still not work...
There is following the results of ver:
MATLAB Version 9.13 (R2022b)
EEGLAB Toolbox to process EEG data Version - see
MATLAB Coder Version 5.5 (R2022b)
Signal Processing Toolbox Version 9.1 (R2022b)
Stateflow Version 10.7 (R2022b)
Statistics and Machine Learning Toolbox Version 12.4 (R2022b)
I suspect whether it is because of my Matlab version or sth...
Pengyuan Sun
Pengyuan Sun 2023년 4월 13일
Problem has been solved after I turned MATLAB from R2022b to 2020a, turned EEGLAB from ver 2023.0 to 2021.0. :)
Thank for your suggestion and patience.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by