Skip to main content

Questions tagged [data-structures]

Questions on using or implementing more or less common data structures such as linked lists, structs, trees, tries, heaps etc. in Mathematica.

Filter by
Sorted by
Tagged with
0 votes
1 answer
92 views

Need explanation on data[[i]][[1]]

I am trying to train a physics model and then check its profile. For this model, data for physics model is defined with: ...
Dean's user avatar
  • 655
0 votes
2 answers
59 views

Interpolation function for data with repeating independent variable

I want to find an interpolation function for data in which the x-variable is repeated (example below). The repetition in data is natural and cannot not be eliminated. Can I somehow use ...
SciJewel's user avatar
  • 381
7 votes
0 answers
109 views

DataStructure's "DynamicArray" underperforms Association?

The documentation for DynamicArray states that it is "An extensible array is useful for continuously appending elements, as well as for efficient element extraction and updating." I tried a ...
Craig Carter's user avatar
  • 4,425
1 vote
2 answers
73 views

Contour plot data extraction and replacing z slices with user defined function

Let's say we have a contour plot of the following, ContourPlot[Cos[x] + Cos[y], {x, 0, Pi}, {y, 0, Pi}, ContourLabels -> True] that gives, we can extract the ...
a019's user avatar
  • 867
0 votes
0 answers
60 views

Long associations of short associations or the inverse, which one should I use?

I don't have enough experiences of using Association or Dataset, and when operating with nested associations I meet the ...
Lacia's user avatar
  • 2,253
2 votes
1 answer
85 views

How can I join non-overlapping TimeSeries so that the gap between any two is considered to be Missing data?

I have a set of time series sampled at one second intervals. For example, ...
Nick's user avatar
  • 403
0 votes
1 answer
75 views

List structure for plotting multiple y-values (with gaps on certain dates) using DateListPlot

I would like to set up a list like this data = {{Date1,y1,y2,y3,y4,y5,y6},{Date2,y1,y2,y3,y4,y5,y6},...} and then use DateListPlot to create various plots, e.g. y1 ...
ConfusedCabbage's user avatar
3 votes
1 answer
71 views

Question on splitting into individual cycle from a list of 30 cycles dataset

Hi I have a set of data and will like to find out I can split these 30 cycles into each individual cycle? Do I use the for loop function in this application. Thanks for the help in advance. ...
Boajj04's user avatar
  • 320
0 votes
1 answer
249 views

How to rotate matrix? [closed]

Consider the matrix 'm1' : m1 = RandomReal[{0, 1}, {100, 100}]; The question is, how to rotate the 'm1' data 45 degrees and extract the matrix 'm2' from it (shown ...
ralph's user avatar
  • 1,029
1 vote
1 answer
77 views

selecting specific part of data set [closed]

I have data set in form {section, Arcangale ,X,Y, type}. Section is the number between 1 to 3 (1,2,3), Arcangale is number change from 0 to 1 something like this (0.0176575), x and y are coordinate (...
Parviz's user avatar
  • 403
0 votes
0 answers
67 views

Heap.m data structure package in Mathematica (Book: Computer Science with Mathematica, CUP press)

The CUP press book Computer Science with Mathematica discusses heaps in section 8.4.3. The package Heap.m is mentioned (for import), containing functions such as HeapPlot. Can you advise where to find ...
ExpressionCoder's user avatar
2 votes
1 answer
152 views

How to convert a dataset into an alternative format

I have the following dataset: ...
Tugrul Temel's user avatar
  • 6,203
19 votes
3 answers
692 views

Difference between HashTable datastructure and Association datastructure

Is there a difference in the runtimes between CreateDataStructure["HashTable"] and <||> in terms of inserting, ...
Lucas Mumbo's user avatar
6 votes
0 answers
231 views

Mutable objects in Wolfram Language

I've seen some posts about mutable objects in WL and some implementations: Once more on object orientation in Mathematica: does it have to be so hard? Immutability, Association and typing Code ...
daneelsan's user avatar
  • 358
0 votes
1 answer
227 views

Import structure from Matlab into Mathematica 12 and nested lookup

I use Matlab and generate data that I save in a structure in a MAT file. I want the results to be loaded into Mathematica, as several analysis and plots are best when done in the latter than in the ...
Marcos GO's user avatar
12 votes
2 answers
400 views

Using DataStructures in FunctionCompile

This is a follow up to this StackExchange question I am trying to do the equivalent of Select on a "FixedArray" data structure. Here is what I have tried so far: ...
Craig Carter's user avatar
  • 4,425
2 votes
0 answers
55 views

Implementing array with partial cyclic data?

I'd like to construct an array where some columns are cyclic. As an illustrative example, take Table[Mod[k, 2^i], {k, 2^10}, {i, 0, 10}] //Grid, where the vast ...
Trev's user avatar
  • 763
1 vote
1 answer
48 views

Logarithmic steps inside a Do

I have trouble, i need to do several computations inside a loop using values in a logaritmic scale, is this possible? Inside of the cicle i create a several data sctructures, and it currently works ...
Isaac Caballero's user avatar
0 votes
2 answers
163 views

Create list of functions, domains, and iterate over (compare to Python code)

In Mathematica, I want to do a mass export of many different animated plots of specific functions with different domains. Because I don't necessarily want the plots to always have exactly the same ...
EllipticalInitial's user avatar
3 votes
2 answers
157 views

Restrict kinds of heads when dealing with level concept

In[1] Map[(# + 7) &, {a, 3 b, {c, d}, e}, {2}] Out[1] {a, 10 (7 + b), {7 + c, 7 + d}, e} But I want feature like ListMap : ...
imida k's user avatar
  • 4,295
2 votes
0 answers
63 views

Handling lists indexed with integer partitions

I am trying to do some exploration around the multi-dimensional version of [truncated moment problem], where I work with various distributions (uni- or multi-variate), and use some truncated moment ...
Gravifer's user avatar
  • 862
0 votes
2 answers
67 views

Finding the number of unique solutions in a .txt file

Well, my question is the following: I have a .txt file that consists of the following data: ...
Jan Eerland's user avatar
  • 2,001
0 votes
1 answer
130 views

Exporting a multi excel files into one file

Suppose a list of students'grades in excel: "excel files" I want to write a program separate student grades to their respective classes and then write them in one excel file. What should I ...
user68344's user avatar
0 votes
0 answers
82 views

Quick questions about a document example for Components and Data Structures

NDSolve can be broken into several basic steps for advanced usage according to Components and Data Structures. In the documentation, a simple example is given as ...
user55777's user avatar
  • 671
1 vote
0 answers
52 views

Problem of application of HashTable in Fibonacci

As we can see the example in ref/datastructure/HashTable This code show the usage of HashTable, Fib is the implement of Fibonacci Number with HashTable. If we ...
HyperGroups's user avatar
  • 8,619
1 vote
0 answers
51 views

Going through all the cases in a rule list

So, I want to have explainable equations derived from replacement rules. I made a Mathematica function that does the following, it takes a list of rules, and it applies them (using ReplaceAll), then ...
Rainb's user avatar
  • 295
6 votes
3 answers
165 views

Customized priority function in DataStructure["PriorityQueue"]?

I'm using Mathematica 12.1. The documentation for DataStructure["PriorityQueue"] claims that, ... the highest-priority element is always returned. The ...
SnzFor16Min's user avatar
  • 2,230
8 votes
2 answers
2k views

Best way to insert element into an ordered list at the correct position?

Suppose I have an ordered list orderedList and I want to write some code that will involve regularly inserting new elements into ...
WillG's user avatar
  • 960
0 votes
0 answers
168 views

Is a tree structure possible in Mathematica?

Let's say I have a vector, vector={1,2,3,4,5,6,7}; and I want to use its items as leaf nodes in a tree datasctructure, then work with them as such, adding new ...
Vojtevo's user avatar
  • 63
1 vote
1 answer
81 views

A more efficient way to interrogate data inside a Dataset: a generic relational map

I have a Dataset that stores the relationships between people IDs (in columns) and the events they attended (in rows). I want to produce a linear text report of those relationships. How can I do this ...
berrynice's user avatar
  • 163
18 votes
2 answers
394 views

How to determine if two mutable data structures are the same?

How can I determine if two mutable data structures (DataStructure) are truly the same? I do not mean checking if they have the same value. I mean checking if they ...
Szabolcs's user avatar
  • 235k
17 votes
2 answers
540 views

How to use DataStructure in FunctionCompile?

The official document said compile a function that can work with data structures but how to use it? There is no doubt that it is possible to use DataStructure as a function parameter: ...
miRoox's user avatar
  • 323
11 votes
1 answer
535 views

How to use the new DataStructure in V 12.1 as is done in classical struct?

There is new DataStructure in V 12.1. I thought at first it is similar to classical struct or record found in other languages and discussed in Struct equivalent in Mathematica? How to use classical ...
Nasser's user avatar
  • 144k
14 votes
2 answers
762 views

COVID-19 Wolfram Data Repository Retrieval

I'm using this dataset to check out the data on new COVID-19 cases. But there are two issues: Two days ago it was working great and it had data up to March 13; 1 day lag. Now when I run the cell in ...
Diffycue's user avatar
  • 1,834
8 votes
1 answer
495 views

Implement abstract algebraic structure

I would like to implement algebraic structures in Mathematica such as groups, algebras, Lie-algebras, Hopf-algebras, ... In particular, after initialising such a structure, I would like to have ...
Gert's user avatar
  • 1,530
0 votes
1 answer
113 views

How to discritize a function domain (break xy-plane to a grid/mesh of squares with vertex values for evaluation)? [closed]

I wrote a code using MATLAB to discritize a function's 2D domain into squares/rectangles, whose vertex data (x,y) I can use to evaluate the function at. Then I sum these values over all vertices to ...
TribalChief's user avatar
2 votes
1 answer
54 views

How to increase the pointsize of the point-markers in the legend of a cluster-chart?

I start the following mock data set: data = RandomReal[{0, 700}, {10^4, 2}]; I use k to define the number of cluster points: ...
Gilmar Rodriguez Pierluissi's user avatar
1 vote
1 answer
68 views

How to view data labels corresponding to cluster points when using FindClusters and Tooltip?

I go straight to the subject; I have the following data set: ...
Gilmar Rodriguez Pierluissi's user avatar
3 votes
2 answers
199 views

Format table output

I'm trying to make a quick code to give me coordinates of some circles to be read in AUTOCAD. When I use the format "Table" or ...
user1111's user avatar
6 votes
4 answers
363 views

Threading data on TimeSeries

Say I have two TimeSeries: x = TimeSeries[{2, 4, 1, 10}, {{1, 2, 4, 5}}] y = TimeSeries[{6, 2, 6, 3, 9}, {{1, 2, 3, 4, 5}}] x has a value at times: 1,2,4,5 y ...
maxgo2's user avatar
  • 145
7 votes
2 answers
520 views

How to import .txt file with missing data?

I have a .txt file that looks like this (direct copy from the file): ...
corey979's user avatar
  • 24k
2 votes
1 answer
120 views

How to join N datasets with common headers?

I am new to Dataset. I'm trying to join many datasets, naively trying to use Join, but I think I'm not using it correctly, or ...
TumbiSapichu's user avatar
  • 1,603
9 votes
1 answer
415 views

Most efficient method for export/import of non-traditional tensor-style dimensions of matrices/tables/lists-of-lists-of-lists(-of lists)?

Hello World! (I did it for my first answer, so it only feels proper...I'm not nostalgic, you are!) OKAY, here we go! Let's start off with the good-stuff, here's my code, made relatively arbitrary, ...
CA Trevillian's user avatar
11 votes
1 answer
273 views

Implementing core data structures

Data structures are your friend. Using the right data structure in the right place means better performance and less work on the programmer's part. This poses a problem in Mathematica, of course, ...
b3m2a1's user avatar
  • 46.9k
6 votes
2 answers
1k views

Convert a huge txt-file into a dataset

My friend has this huge txt-log of sea levels. He wants to organize it into a dataset. After importing it this file a used StringSplit to separate it into rows, then to singular elements ...
Artem Anisimov's user avatar
0 votes
1 answer
198 views

How can I translate some JavaScript code into Mathematica code? [closed]

I am a programmer and would like to understand another field outside of the procedural thinking of if-else and for. I would like ...
user avatar
14 votes
1 answer
982 views

Pascal records and Mathematica programming

Background: "experienced" Pascal-programmer (DOS-era, never got into OOP) proud owner of Mathematica ver 11.2 have used Mathematica for years to do my share of number crunching and plotting to ...
Jyrki Lahtonen's user avatar
13 votes
6 answers
282 views

How to invert MapIndexed on a ragged structure? How to construct a tree from rules?

I have an arbitrary ragged nested list-of-lists (a tree) like A = {{a, b}, {c, d}, {{{e, f, g, h, i}, {j, k, l}}, m}, n}; Its structure is given by the rules <...
Roman's user avatar
  • 47.5k
4 votes
2 answers
924 views

Converting from "matrix" data into "coordinate" data

Say I have data which looks like data1 - this is "matrix" like data (is there a better descriptor?). The data looks like a matrix, and at each point in the matrix, ...
Tomi's user avatar
  • 4,376
4 votes
0 answers
248 views

Approximate Nearest Neighbors in Mathematica?

Is there any support for Approximate Nearest Neighbors (ANN) in Mathematica or third-party packages? I'm looking for a good implementation of locality sensitive hashing for applications where ...
M.R.'s user avatar
  • 31.5k