To get the field names from a structure in Matlab, you can use the fieldnames function. Here's an example:
main.m
```
% Define a sample structure s = struct('field1', 123, 'field2', 'abc', 'field3', [123]);
% Get the field names fields = fieldnames(s);
% Display the field namesfor ii = 1:numel(fields)
disp(fields{ii})
end ```
This will output:
```
field1
field2
field3
```
You can then use the `fields` variable to access the fields of the structure programmatically. For example, to get the value of the `field1`, you can do `s.(fields{1})`.