Questions tagged [accumarray]

accumarray is a MATLAB function that is used to accumulate elements in a vector or matrix based on another vector or matrix of indices. accumarray is commonly used for calculating histograms, grouping values based on certain criteria or applying specific functions to grouped data once they are grouped with accumarray. It is currently one of the most versatile functions in MATLAB's native library and was available since MATLAB 7, R14.

66 questions
1
vote
1 answer

How to deal with paired values?

Say I have a vector of independent variable values v =[ 1 2 2 1 1 .5 1 2 .5 .5 1] and a vector of response variables u = [ 5 22 20 4 8 .2 5 12 0 .5 6] I want to plot u vs. v with errorbars, the method needs to work for 100s of possible values for…
WetlabStudent
  • 2,556
  • 3
  • 25
  • 39
1
vote
1 answer

grouping and summing (evaluating functions) on matrix-values in matlab

Many threads here show that accumarray is the answer in matlab for grouping (and calculating) values by index sets. As this works fast and fine, I need to have somethin similar for bigger (ND) data-fields. Let's assume an example: We have a…
Bastian Ebeling
  • 1,138
  • 11
  • 38
1
vote
2 answers

MATLAB: n-minute/hour/day averages of a time-series

This is a follow-up to an earlier question of mine posted here. Based on Oleg Komarov's answer I wrote a little tool to get daily, hourly, etc. averages or sums of my data that uses accumarray() and datevec()'s output structure. Feel free to have a…
Fred S
  • 1,421
  • 6
  • 21
  • 37
1
vote
1 answer

How to make Accumarray work with Struct array?

Can this be done? Basically, I have a struct array val (contains a list of my custom structure) and I want to multiply all the elements together using custom multiply function Multiply and I don't want to use loop. I tried to use accumarray(indx,…
Dryland
  • 86
  • 1
  • 3
0
votes
1 answer

Translate accumarray (Matlab) to python

I have to translate a Matlab script to python, it transforms some complicated data into an array. And I don't know how to translate this part of the code: accumarray([j2,i2],iq,[],[],NaN) That is in Matlab, the shapes of j2, i2 and iq are (1362730…
0
votes
1 answer

Is there accumarray equivalent in pytorch?

Let's assume I have a feature tensor [f1, f2, f3, f4]. I want to pool the features according to an arbitrary index tensor (e.g. [0,2,1,0]). Then the results would be [f1+f4, f3, f2]. I found that accumarray is the function that I want, but it is on…
Jun
  • 135
  • 1
  • 7
0
votes
0 answers

How to use python accum function with 3d array

I recently try to transfer some function from matlab to python. A function in matlab called "accumarray", accumarray(3d_array(10*10*10),1), the output is also 101010 3d array. But when I try to do the same in "accum" function in python, I can not…
yuan
  • 1
  • 2
0
votes
0 answers

How to split the shortest path according to the distance

I have the shortest path connecting a set of points, where the starting point A is fixed. I have the total distance as well as the pairwise distance, as well as the ordered indexes. I want to split the path: if the total distance of the path is…
0
votes
0 answers

Averaging properties of a 3D point cloud on a 2D grid with sliding kernel (Matlab)

I have a 3D point cloud organised in a 3-colums format [x,y,z], with additional properties of each point from column 4 onwards. Note that the distance of all points is random. I am trying to implement a moving filter similar to blockproc in order to…
e5k
  • 194
  • 1
  • 14
0
votes
2 answers

Averaging replicate data in Matlab, multiple variables

I'm trying to average replicate data in MATLAB and running into some difficulty. The variables are depth, Var1, Var2. Sometimes there is a replicate in Var1, sometimes there is a replicate in Var2, sometimes there is a replicate for both Var1 and…
RED_H
  • 1
0
votes
2 answers

Extract values from rows satisfying a given criteria

I would like to calculate total income in a shop every 30 minutes, I have a dataset like: hour minute price 0 1 12,5 0 1 10 0 2 15 0 3 15 I have tried to implement the totalling like…
ömer çel
  • 23
  • 3
0
votes
0 answers

Cumulative sum computation from hourly rainfall data MATLAB

I have a hourly rainfall timeseries from 1970 to 2003. I want to calculate: n-hour values, n = 2,3,6,12,24 & 48 hr. 24-hr rainfall data can be calculated by accumulating 24 consecutive 1-hr data. Similarly, 48-hr rainfall can be calculated by…
Poulomi
  • 25
  • 5
0
votes
1 answer

Sum of elements in a vector using intervals

Let's say I have a vector named vect = [1 2 3 4 5 6 7 8 9] and another vector named intervals = [1 3 6 9]. Is it possible to get another vector of partial sums of elements in vest, using intervals? I want to do something like this: Partial sum 1 = 1…
Adrian Pop
  • 1,879
  • 5
  • 28
  • 40
0
votes
1 answer

Matlab - Accumarray confusion?

I'm just not understanding how exactly accumarray works. I checked the official matlab documentation, but I'm still unable to comepletely understand. If it's something like this, where: subs = [1 3 4 3 4] val =…
ocean800
  • 3,489
  • 13
  • 41
  • 73
0
votes
1 answer

Setting an Hourly x-Axis to plot Accumarray in Matlab

In matlab I have used accumarray() to create a new vector with 3 columns of integers. Column 1: date (just the day); Column 2: hour; Column 3: Sample Value. 19.0000 9.0000 25.6937 19.0000 10.0000 30.2616 19.0000 11.0000 32.2840 19.0000 …
James
  • 291
  • 1
  • 3
  • 13