robustfit error

2 次查看(过去 30 天)
Emily
Emily 2011-3-10
I'm trying to run the robustfit function on my data using this command [b,stats] = robustfit([FA_DMN(1,5,:)], DMN_functional_global(1,5,:))
But it returns the error:
??? Error using ==> ctranspose Transpose on ND array is not defined.
Error in ==> statremovenan at 16 y = y';
Error in ==> robustfit at 99 [anybad wasnan y X] = statremovenan(y,X);
My dataset doesn't have any NaN's in it to remove and the data that I'm inputting are values on two measures for 35 subjects that I'm trying to correlate. I ran the corrcoef function on these data successfully but want to try robustfit to take care of the outliers. I'm a matlab beginner so I don't have the programming and troubleshooting skills to figure this out. Thanks! Emily

回答(1 个)

Matt Tearle
Matt Tearle 2011-3-10
I'm guessing that the NaN thing is a red herring -- I think that's just where the error happens to be thrown (ie some general checking algorithm behind the scenes that looks for NaNs).
The real problem is that MATLAB is a bit idiosyncratic with the way it deals with multidimensional arrays. You have 3-D arrays which you're indexing into... that's all well and good, except that the result isn't a vector like you might expect:
A = randi(5,3,2,4)
A(2,1,:)
Note that the output is a 1-by-1-by-4 array. Although that's 1-dimensional, MATLAB sees it still as a 3-D array. The solution is to squeeze it:
squeeze(A(2,1,:))

类别

Help CenterFile Exchange 中查找有关 Descriptive Statistics 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by