array of structures in matlab
1 次查看(过去 30 天)
显示 更早的评论
how to create array of structure,and array contains 100 element. i want to sort array on the basis of second field of array.
0 个评论
采纳的回答
Walter Roberson
2015-10-10
YourStructureName(100) = struct('firstfield', [], 'secondfield', []);
And there you have a struct array of 100 elements, each of which has two fields.
2 个评论
Walter Roberson
2015-10-10
There is no basis for sorting an array based upon empty fields. If the fields are not empty then you need to define how to determine whether one field content sorts before another. For example if YourStructure(317).secondfield = {'Red Rover', 17}, should that sort before or after YourStructure(111).secondfield = [1/1000-3/507i, inf; nan, -5099e42] ?
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Shifting and Sorting Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!