Averaging over specific columns in a for loop not working
정보
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
이전 댓글 표시
CompanyTable = cell(nCompany,4);
for n = 1:nCompany
%determine and display the name of the company studied
thisCompany = uniqNames{n};
fprintf('\nStudying %s \n',thisCompany);
tf = strcmp(row1,thisCompany);
thoseCompany = cell2mat(CompanyData(tf,3));
tmp = movmean(CompanyData,nCompany,1);
Averagelate = tmp(:,nCompany:nCompany:end);
%latetime = [shipData{2:end,thisCompany}
Currently I am looking to average out companies data based off certain times. I saw a thread about using movmean and I have attempted that, but I am currently getting "Invalid data type. First input must be numeric or logical." CompanyData is an array of only nunmeric values.
댓글 수: 4
Rik
2020년 3월 19일
Where did you define this variable? The line above it suggests it is not a numeric array, but a cell array instead.
Taylor Sumlin
2020년 3월 19일
Rik
2020년 3월 19일
What does class(CompanyData) return?
Taylor Sumlin
2020년 3월 19일
편집: Rik
2020년 3월 20일
답변 (1개)
You can use cell2mat to convert the cell to a double array. Then it will work with movmean.
댓글 수: 0
이 질문은 마감되었습니다.
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!