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
1 answer

Convert Cell to Struct in Matlab

I'm trying to access contents of a cell array which has 4 structures. celldisp(tracks_array); gives output: tracks_array{1} = kalmanFilter: [1×1 vision.KalmanFilter] id: 0 totalVisibleCount: 1 …
Anand C U
  • 885
  • 9
  • 29
0
votes
1 answer

Reference to non-existent field when using variable for struct access

I'm very new to Matlab and maybe a very basic question, but I need help: I have a path: file = C:\this\is\path\to\my_file.mat This is a file which contains nested structure and I need just to access one variable. In my script, first I need to get…
JohnDoe
  • 825
  • 1
  • 13
  • 31
0
votes
1 answer

Matlab: Performing operations with 'struct' in image processing

I have two images - one binarized, and one original. I use the binarized image to segment using bwconncomp and then for every blob/region, I want to sum the pixel-intensities from the original image. I do that by: blobMeasurements =…
Sovm
  • 51
  • 7
0
votes
1 answer

plotting structure elements and dimensions in matlab

I'm trying to create a 3D plot in Matlab of a structure element, Bstruct.scen_1. In this structure, each row is a year, each column is a distance, and the cell value is a population size (so for example, row 3, column 7 would yield the number of…
AFH
  • 665
  • 1
  • 9
  • 28
0
votes
2 answers

How to add an array (double) as a field to a struct variable?

I have a structure variable and want to add a field and fill the row with the values of an array (double). The following code works but isn't very nice. Is there a more elegant way to add a field including values without the use of the mat2cell…
S Geurts
  • 118
  • 7
0
votes
1 answer

Matlab struct of vectors to vector of struct conversion

How can I convert arrays x(1:N), y(1:N) into a structure S(1:N) with fields .x and .y in a fast way without for-loop? I can easily convert x, y into a struct of arrays: S.x = x; S.y = y; Since I need to work with individual sets of (xi, yi), how…
Sairus
  • 384
  • 1
  • 15
0
votes
1 answer

MATLAB: Storing values in a structure

Good day MATLAB pros, I have a long list of (single value) variables in my workspace that has to be stored into an array for every loop of execution. Here's a simple example: Variables in the workspace: a = 1; b = 2.2; c = 3.4; d = [0.5 0.7 1 1.2…
Bensa
  • 127
  • 2
  • 13
0
votes
1 answer

Iteratively print matlab struct

I have a matlab struct with the following structure Tree: feature : numerical value (= 1) tru: numerical value (= 2) gain: numerical value (= 3) left: struct with left node right: struct with right node How do I print this out in the form of a…
0
votes
1 answer

Combine multiple structures into one

I have a matlab workspace that only contains structures. All structures have the same fields. Imagine I have three structures in the workspace with names: B00002N6AA B00002N6VF B00004OKOP I can combine them into a single structure by…
phdstudent
  • 1,060
  • 20
  • 41
0
votes
1 answer

assignment of structure field values in loop - matlab

I am trying to assign the field values of structure in loop. Structure declaration with empty values: result_struct = struct('a',{},'b',{},'c',{},'d',{}) I am assigning values in loop like that: % assume a, b, c, d are variables in my workspace %…
asif
  • 3
  • 2
0
votes
1 answer

Exporting a Matlab Variable Struct having multi dimension values to Excel

I have the following MATLAB struct with two fields: I am trying to export this to Excel in two columns (or to notepad having just the second column of objectBoundingBoxes). When the field dimensions are 2x4 or 1x4, it displays semi colon separated…
Abdul Jabbar
  • 2,573
  • 5
  • 23
  • 43
0
votes
1 answer

Where are these `New Name` and `[]` coming from?

I'm learning about structure iteration, and trying to output things in the loop patient(1).name = 'John Doe'; patient(1).billing = 127.00; patient(1).test = [79, 75, 73; 180, 178, 177.5; 220, 210, 205]; patient(2).name = 'Ann…
0
votes
1 answer

Attaching function to Matlab struct

Is it possible to attach a function to a class property of type struct? Intended usage: % Definition: classdef a < handle properties bar end methods function obj = a() obj.bar = struct; %obj.bar.attachFunction('apply',…
casparjespersen
  • 3,460
  • 5
  • 38
  • 63
0
votes
1 answer

Iterating through Struct MATLAB

Below is what I have so far. I need to iterate through each field of rxnsBothKaletaS struct where each field represents a nx4 cell. I need to extract information out of the first column of that cell as a single string separated by commas and then…
0
votes
2 answers

How to convert a struct to a matrix

I have a 10 x 10 struct with four fields a,b,c,d. How do I convert this struct to a 10 x 10 matrix with entries only from the field a?
Kenneth.K
  • 135
  • 5