Using ACCUMARRAY
(Originally posted on Doug's MATLAB Video Tutorials blog.)
ACCUMARRAY is one of my favorite functions that I never seem to need outside of MATLAB golf problems. I present this to you with the hopes that knowing it exists allows you to use it at just the right time. The video discusses the following code:
sales.rep = [1 2 1 3 4 6 2 3 1 1];
sales.amount = [1 1 3 1 5 2 2 4 1 5];
numReps = max(sales.rep);
sales.total = zeros(1,numReps);
for i = 1 : numel(sales.rep)
sales.total(sales.rep(i)) =...
sales.total(sales.rep(i)) + sales.amount(i);
end
sales.accum = accumarray(sales.rep', sales.amount)'
Recorded: 2 Oct 2009
Featured Product
MATLAB
Up Next:
Related Videos:
Seleccione un país/idioma
Seleccione un país/idioma para obtener contenido traducido, si está disponible, y ver eventos y ofertas de productos y servicios locales. Según su ubicación geográfica, recomendamos que seleccione: .
También puede seleccionar uno de estos países/idiomas:
Cómo obtener el mejor rendimiento
Seleccione China (en idioma chino o inglés) para obtener el mejor rendimiento. Los sitios web de otros países no están optimizados para ser accedidos desde su ubicación geográfica.
América
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia-Pacífico
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)