Questions tagged [matlab-struct]

For questions about the MATLAB structure datatype.

A structure is a datatype in MATLAB. It is different from cells and arrays in that it uses field names, and within fields one can store other data, also of type struct, cell, array, etc.

MathWorks has a tutorial on accessing data in a structure array.

The basic function to create one is, among others, struct.

145 questions
1
vote
2 answers

Access data in structures when field names are unknown

I have data as a struct with several layers, for example: data.A.B The data I want to access is in layer B. But the problem is that field names in B can be different depending on where the data comes from. Therefore I can't just…
aceS
  • 13
  • 3
0
votes
0 answers

import data from a matlab structure and store it in matrices in python

I have some data stored in a 1x1 with 8 fields struct in matlab. I want to store the data of each field (which is a table) in a matrix in Python I tried this: import scipy.io import numpy as np # Load the .mat file data =…
Mayssa
  • 1
  • 2
0
votes
0 answers

how to access to a array cell or a structure field in a matlab matrix thanks to the value of a variable?

I have a structure called : time_record_1 and a variable called field which is equal to "d3", and I want to do : time_record_1.field = value (the field d3 already exists). When I do it, it creates a field named "field". How can I do ?
0
votes
1 answer

Convert Python numpy array to specific Matlab format

I am trying to convert python data to matlab format. It is saving a matlab file that has a data_array of 3x7x5 double. But I need a file with 1x3 Cell (matlab cell) and in each cell 7x5 double matrix should be there. I tried to create list of…
abhishek
  • 5
  • 2
0
votes
1 answer

How to generate every possible permutation of a MATLAB structure

I have a MATLAB template structure that I'm using as a basis for a more complex output structure conditions = {'Listen',':=:'}; items = ["apple" "duck"]; % 2 items stims = cellstr([ ... items, ... % text items+".PNG", ... % picture …
0
votes
1 answer

What is the best practice to recursively extract data from a nested structure in matlab?

I'm trying to exctract some data from a nested structure in a recursive manner. First, I know that this has a field (values) which repeats itself inside the nested structure. Secondly I know that the structure which has those values has only…
Cassius
  • 5
  • 2
0
votes
0 answers

convert MATLAB table column from array of doubles to string

I'm having trouble converting a column in my MATLAB table. Each row of this column contains a 802x1 double. For each row in this column, I'd like to merge all of the numbers into one large string (basically so I can have a flat table instead of a…
Katie
  • 13
  • 2
0
votes
1 answer

Modify structure array from nested function with function handle

I am trying to modify a structure array from within a nested function, where the nested function is 'returned' through a function handle. From what I know, you cannot modify the structure array from the 'outer' function, since MATLAB pass arguments…
rad
  • 157
  • 1
  • 9
0
votes
2 answers

How do I sort a structure array based on one field in MATLAB?

I previously posted on how to display and access structure array content. The file consisted of states, capitals, and populations. Now I'm having trouble in created a new structure by organizing these states in alphabetical order. I did this by the…
Nick
  • 85
  • 2
  • 3
  • 5
0
votes
2 answers

Find Index of Structure Array with multiple criteria

I have a structure array as follows: configStruct = 20x1 struct array with fields: type id manufacturer model How do I find the index of an element with fields, for example: type: 'Mainframe' id: '5' …
Rek
  • 45
  • 4
0
votes
1 answer

Import a variable from .mat and export to CSV

I have a .mat file which contains a struct (called wiki), in which there is a field called full_path containing data as follows: ans = Columns 1 through 4 {'17/10000217_198…'} {'48/10000548_192…'} {'12/100012_1948-…'} …
Anurag
  • 37
  • 1
  • 6
0
votes
1 answer

Convert a class to structure and store in a .mat file - MATLAB

I have a class which has some properties that they are objects of other classes, when I convert the class to a struct and check the data, the full information of all properties exist. but after storing it to a .mat file, when I load the data, the…
Someone
  • 163
  • 1
  • 3
  • 13
0
votes
1 answer

Assigning values to fields in a 2D array in MATLAB

I have a relatively simple problem that my Google-fu hasn't managed to solve that I think must have a solution. I have a m-by-n array of values, and I am trying to assign them to fields in a m-by-n structure. This is trivial using a for loop (shown…
Alex
  • 23
  • 6
0
votes
1 answer

Looking up data entries assigned to fields in structures

I have a structure in MATLAB with over one hundred data entries per field. struct.p = [1 2 3 4 ...] I want to be able to search for a field by typing in a data entry. For example, typing 2 will tell me that the field is 'p'. I've tried combining…
0
votes
1 answer

How to export field values from a struct to another struct in Matlab?

I have a struct of 283 Area values and I want to copy the higher than 1000 values to a second struct with a for function. I have writen the code I need like this Lbp = regionprops(Lblack, 'Area'); Lbp.Area; [r,c]=size(Lbp); B(r,c) = struct(); for…
Kate
  • 53
  • 1
  • 1
  • 6