convert cell array with struct information to struct

2 ビュー (過去 30 日間)
Andreas Harrer
Andreas Harrer 2017 年 6 月 22 日
回答済み: Massimo Ciacci 2019 年 11 月 21 日
Hello,
I am using the OPC-Toolbox. The Information of the Item-structure on the server is already given as a 2996x1 cell:
itemID =
Simulator
Simulator.System
Simulator.System.Allow Online Setting
Simulator.System.CRC
Simulator.System.Vehicle1
...
I want to get this old 1x1 struct beginning with "Simulator." back.
because of the autocomplete of matlab.
I am helpful for any Information.

回答 (2 件)

Binu
Binu 2017 年 8 月 4 日
There is a cell2struct function structArray = cell2struct(cellArray, fields, dim)

Massimo Ciacci
Massimo Ciacci 2019 年 11 月 21 日
function structArr = cellArray_2_structArray(cellArr)
N = numel(cellArr); % N cells with 1 struct each
structArr = repmat(cellArr{1}, N, 1 ); % array of structs
for ii=1:N
structArr(ii) = cellArr{ii};
end
How about a poor man solution like this? The advantage over cell2struct is that here you don't need to specify the fields already available in cellArr{1}.

カテゴリ

Help Center および File ExchangeUnified Architecture についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by