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
0
votes
2 answers

How to add new field to an non-empty struct in Matlab?

I have a 1-by-565 struct array, GRID, where each struct has five fields: A B C D E Each field has some value and now I need to add a sixth field, G, to every element in GRID. I tried: GRID(:).G=addfield(G,[]) GRID(:).G=[] but that doesn't work.…
subha
  • 65
  • 9
0
votes
1 answer

Save all but some fields of a struct to a file in MATLAB

I have a struct variable which is parameters with some other variables ex foo1 ,foo2. parameters has 20 fields. ex. a,b,c,d,e ... I want to save only 18 fields. I don't want to save parameters.a and parameters.b. So I want to save parameters except…
toygan kılıç
  • 422
  • 4
  • 16
0
votes
1 answer

Feed the MATLAB structure output to a new structure

If I have a MATLAB structure output like f1: [0 0 0 0 0 0 0 0 0 0] f2: 'a' How can I feed this output to different structure without manually doing F = struct('f1', [0 0 0 0 0 0 0 0 0 0], 'f2', 'a'); In other words I need to feed the data in…
stinglikeabeer
  • 455
  • 1
  • 3
  • 11
0
votes
2 answers

How to create struct with variable name

I would like to create a struct that is named after a dynamic variable. Something like: for t = 1:2 for b = 1:70 Father.t.b.A = A; Father.t.b.C = C; end end and when looking at Father there is Father.1.1.A, Father.1.2.A,…
Maguzi
  • 23
  • 5
0
votes
1 answer

Matlab Struct Manipulation

I have a struct, D whos D Name Size Bytes Class Attributes D 1x128 93372 struct Opening up the variable from the workspace, I have 128 <1x1 struct> fields. How can I delete, for example, all…
0
votes
1 answer

Finding an element of a structure based on a field value

I have a 1x10 structure array with plenty of fields and I would like to remove from the struct array the element with a specific value on one of the field variables. I know the value im looking for and the field I should be looking for and I also…
Leon
  • 408
  • 1
  • 6
  • 17
0
votes
0 answers

how create another field in a struct in matlab

I have a struct with information. I want to put more field and put in the new fields information from other tables. How i put new fields in a struct that have information? At matlab! Thanks
0
votes
1 answer

How to remove structs from Matlab array for specific struct.field values

Everytime I try editing arrays of structs by field, I discover I really need to take a few weeks and try to really learn Matlab. Right now, I have an array of structs, where each struct has fields along the line of: x.fruit, x.color, x.season,…
user1245262
  • 6,968
  • 8
  • 50
  • 77
0
votes
1 answer

How to remove empty strings from a MATLAB array of structs

I have a MATLAB array of structs with a field called image_name. There are a few entries where x(n).image_name = [] (i.e., the nth row of the struct array has an image_name that's empty) I would like to remove them by trying something along the…
user1245262
  • 6,968
  • 8
  • 50
  • 77
0
votes
1 answer

Construct a struct from textscan output in MATLAB

I have a tab-separated file like this: refseq gene symb locus_id chr strand start end cds_start cds_end status chrm ENST00000456328.2 ENST00000456328.2 DDX11L1 00000456328 chr1 1 11868 14409…
tsznxyz
  • 199
  • 1
  • 7
0
votes
1 answer

Importing matlab structs within structs in python

I have MATLAB data files which contain multiple structs within struct that i want to import into python. In MATLAB, if main_struct is the main file, I can get down to the data I need by - leaf1 = main_struct.tree1.leaf1 leaf2 =…
NeuronGeek
  • 47
  • 5
0
votes
3 answers

Delete entire rows in struct array matlab depending on field entry

I have the 1x1008 struct array EEG.event with fields latency duration channel bvtime bvmknum type code urevent I want to delete all rows where entry in field EEG.event.type = 'boundary' or 'R 1' I tried the following loop: for b =…
C_Hut
  • 31
  • 8
0
votes
1 answer

Join two different size cells in the same struct

I want to put together 2 cells of different sizes in the same struct. For example: a = {'one', 'two', 'three'}; b = {'four', 'five', 'six', 'seven'}; struct("setA", a, "setB", b); Whenever I try to do this, MATLAB throws the following…
Paulo MiraMor
  • 1,582
  • 12
  • 30
0
votes
1 answer

Save fields of branched structure with dynamic names in matlab

I need to know how to save just one branch of a structure in MATLAB. The structure contains more levels with more fields per level. For example: data.level1.level21 data.level1.level22 I want now to save the branches data.level1.level21 and…
kyi
  • 43
  • 1
  • 10
0
votes
1 answer

From struct to cellarray - Matlab

I am working with wireless networks in Matlab. I have created the contact table, meaning the two nodes having contact and the starting and ending time of the contact. The contact table is in the form of a struct in Matlab as shown below:…
vasouli
  • 21
  • 8
1 2 3
9
10