Hi(adsbygoogle = window.adsbygoogle || []).push({});

The following structure has 2 elements.

people = struct(...

'name',{'bob', 'john'},...

'numKids',{0, 2}, ...

'kidsage',{[],[12,9]});

each element people(1), people(2) has three frields (name, numKids, kidsage)

Instead of declaring the structure in one line as above, I would like to define it one field at a time.

The closest working example I've been able to come up with is

people = struct

people.('name') = {'bob, 'john'}

people.('numkids') = {0, 2}

people.('kidsage') = {[], [12, 9]}

But defined in this way, the people structure only has one element.

ie.

people(1) =

name: {'bob' 'john'}

numkids: {[0] [2]}

kidsage: {[] [12, 9]}

Can anyone help?

**Physics Forums | Science Articles, Homework Help, Discussion**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# MatLab structures

Loading...

Similar Threads for MatLab structures |
---|

MATLAB MATLAB: forces acting on an object |

MATLAB Matlab histogram |

MATLAB Sovling Bernoulli's differential equation in matlab? |

MATLAB Matlab-like software |

MATLAB Matlab data into bins |

**Physics Forums | Science Articles, Homework Help, Discussion**