when i try to run mean function
조회 수: 6 (최근 30일)
이전 댓글 표시
%load('Ftr.mat'); %load first 1000 data
data = xlsread('data.xlsx','Sheet1');
Ftrain= data(1:990, :);
Ftest=data(991:1000, :);
X=Ftrain;
[n,p] = size(X); %n = number of observations/samples
%mean
c=mean(X);
mu=repmat(c,n,1);
%standard deviation
d=std(X);
%Upper control limimt
UCL=c+3*d;
x=repmat(UCL,n,1);
%Lower control limimt
LCL=c-3*d;
y=repmat(LCL,n,1);
P=1:n;
it shows error.
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 XbarRS3DC (line 8)
c=mean(X);
답변 (1개)
Walter Roberson
2020년 12월 1일
No, that error literally cannot happen with the code you posted.
In your previous question, you posted an error that can only occur if Data is datatype table(), which was not possible when using xlsread(). We can predict that your current problem involves the same thing, that somehow Data is datatype table() even though that is not a possibility when you use xlsread() .
That problem can occur if you use readtable() instead of xlsread().
If you were using readtable() then you would need to pick out numeric columns, and ask to extract the numeric content. For example,
X = Ftrain{:, 1:3};
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!