MATLAB: How to separate the field from a structure in MATLAB

cell arraycell arraysMATLABnonscalar structurestructures

I have a structure which is attached with this file named as 'shape.mat'. The structure contains the following fields: Geometry Boundary X Y…etc Now i want to separate X and Y field from the structure and store it in a cell named x_constraint and y_constraint respectively. Can it be done?

Best Answer

Your structure seems to be a nonscalar structure, so try using curly bracket:
load('shape.mat');
x_constraint = {S.X};
y_constraint = {S.Y};