the structure has a fieldname and an array as value. there are also elements from this structure. now i want the field 1x1 from element 1 in matlab

Suppose we have a structure myStruct which has a field named fieldname whose value is an array. We also have an element of this structure named elem1 and want to access the value of the 1x1 element from its fieldname array. Here's how we can do this in MATLAB:

main.m
% create the structure
myStruct.fieldname = [1 2; 3 4];
elem1 = myStruct;

% access the value of 1x1 element from elem1's fieldname array
value = elem1.fieldname(1, 1);
169 chars
7 lines

In this example, elem1.fieldname(1,1) will give us the value of the element located in the first row and first column of fieldname array which is 1. We can store this value in a variable named value for further use.

gistlibby LogSnag