Borrar filtros
Borrar filtros

Translate code R to Matlab code

1 visualización (últimos 30 días)
Camilo  Corredor
Camilo Corredor el 17 de Ag. de 2015
Comentada: Camilo Corredor el 17 de Ag. de 2015
Hi all,
I have this R code
Data<-aggregate(Vtec, by=list(Time), FUN = "mean" )
I want to translate this code R to Matlab code. This code groups the Vtec associated with the variable Time and averages. I've read the documentation and I found that I can use a function accumarray but I don't know how to use it
Greetings from Colombia

Respuestas (1)

Walter Roberson
Walter Roberson el 17 de Ag. de 2015
If you have the Statistics toolbox then consider using a table and grpstats
Otherwise,
[utime, ~, utimeidx] = unique(Time);
meanTime = accumarray(utimeidx, Vtec(:), [], @mean);
output = [utime, meanTime];
I put the two together in one output so that you would be able to tell which Time value was associated with which meanTime.

Categorías

Más información sobre Tables en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by