How to calculate coefficient of variation for every element in Matrix?

조회 수: 65 (최근 30일)
Saad Alqahtani
Saad Alqahtani 2021년 8월 2일
댓글: Saad Alqahtani 2021년 8월 2일
Hi,
I'm trying to calculate coefficient of variation for every elemnt in an array but I kept getting this error:
Error using reshape
Product of known dimensions, 521250, not divisible into total number of elements, 1.
here is my code:
(datan) is my raw data with the length of 521250
tm= ceil(length (datan));
mn= mean(reshape([datan(:)],tm,[]));
sd=std(reshape([datan(:)],tm,[]));
cv=reshape((sd./mn)*100,[],tm);
Any help would be appreciated. Thanks in advance!

답변 (1개)

David Hill
David Hill 2021년 8월 2일
cv=std(datan,0,'all')/mean(datan,'all');
  댓글 수: 1
Saad Alqahtani
Saad Alqahtani 2021년 8월 2일
Thanks for the answer. But I'm hoping to get an array of cv as the same size as the datan. So, my ultimate goal is tha I can see how the cv changes over time. However, from the line I got from you, I only get one value which is not what I'm trying to do. Thanks again.

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

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by