How to calculate the coefficient of variation in Matlab
175 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have 90000 time data and 90000 speed data, and the time are equally averaged. I need to calculate the coefficient of variation for every 30 sec and plot it.
Here is my code, and I got 3000*3000 for the coefficient of variation. So I cannot plot it. Does anyone know how to fix it?
a=time;
b=speed;
n=30;
time_aver=reshape(a,n,[]);
speed_aver=mean(reshape(b,n,[]));
%
time_std=reshape(a,n,[]);
speed_std=std(reshape(b,n,[]));
%
speed_CV=speed_std\speed_aver;
plot(time_aver,speed_aver,'LineWidth',2);
hold on
plot(time_std,speed_std,'LineWidth',2);
0 Kommentare
Akzeptierte Antwort
dpb
am 23 Feb. 2021
Bearbeitet: dpb
am 11 Aug. 2021
N=30;
mn=mean(reshape([time(:),speed(:)],N,[]));
sd=std(reshape([time(:),speed(:)],N,[]));
cv=reshape(sd./mn,[],N);
returns CV of time, speed as columns in cv.
4 Kommentare
Katharina Hofer
am 11 Aug. 2021
Shouldn't it be std divided by the mean, not mean divided by the std?
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!