Partial least square error
3 次查看(过去 30 天)
显示 更早的评论
When I am trying to run the following code the following error occures. what is the reason?
x=load('CODTOCTDS.mat');
y=load('COD.mat');
[XL,YL,XS,YS,BETA,PCTVAR,MSE,stats] = plsregress(x,y)
Error using sum
Invalid data type. First argument must be numeric or logical.
Error in mean (line 127)
y = sum(x, dim, flag) ./ mysize(x,dim);
Error in plsregress (line 176)
meanX = mean(X,1);
Error in CODpred (line 4)
[XL,YL,XS,YS,BETA,PCTVAR,MSE,stats] = plsregress(x,y)
0 个评论
回答(2 个)
Umar farooq Mohammad
2020-3-31
As per the error, it is failing at the sum step. so i know some if the simmilar error due to my previous experience.
In your data you might be having an cell array so You would need to convert the cell array into a double array using cell2mat or something similar. Please check if this helps!!
Or else please share your data which you are trying to load so that it will give a clear picture to help..
Chuan Wang
2021-7-20
I also have a similar error when I do the following:
X=readtable('X.xlsx','VariableNamesRange','A2:A301',...
'VariableNamesRange','B1:HZ1','DataRange','B2:HZ301');
Y=readtable('Y.xlsx','VariableNamesRange','A2:A301',...
'VariableNamesRange','B1:B1','DataRange','B2:B301');
[XL,YL,XS,YS,beta,PCTVAR,MSE,stats] = plsregress(X,Y,10);
The error messages are:
Error using sum
Invalid data type. First argument must be numeric or logical.
Error in mean (line 127)
y = sum(x, dim, flag) ./ mysize(x,dim);
Error in plsregress (line 176)
meanX = mean(X,1);
Error in PLSregression (line 7)
[XL,YL,XS,YS,beta,PCTVAR,MSE,stats] = plsregress(X,Y,10);
Does anyone know how to solve the problem?
In the Y cells, there are blanks in the data. Does this cause the problem? If yes, how to handle this?
Thanks,
CB
0 个评论
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!