MATLAB Answers

This structure does not have a field 'rbm'; new fields cannot be added when structure has been read or used. #MATLAB Coder

35 ビュー (過去 30 日間)
Virtualkeeda
Virtualkeeda 2018 年 8 月 18 日
回答済み: Ryan Livingston 2018 年 8 月 20 日
The cope snippet is here:
function dbn = randDBN( dims, type )
#codegen %coder.extrinsic('cell');
% dbn.rbm = cell( numel(dims)-1, 1 ); % dbn=struct('rbm',zeros(3,1)); % dbn.rbm{1}=0;
dbn.rbm{numel(dims)-1, 1}=[]; % dims is [1 2 3 4]
Earlier I tried to initialize dbn.rbm with 0. it didnt worked as it was referring to the non-cell array element.

  1 件のコメント

Virtualkeeda
Virtualkeeda 2018 年 8 月 18 日
Earlier I was using : dbn.rbm = cell( numel(dims)-1, 1 );
but cell operation cant be applied to struct in code generation. thats why I started using dbn.rbm{numel(dims)-1, 1}=[];

サインインしてコメントする。

回答 (1 件)

Ryan Livingston
Ryan Livingston 2018 年 8 月 20 日
MATLAB Coder support for cell arrays inside of structures was added in MATLAB R2017b:
In R2017b the code:
function dbn = randDBN( dims, type )
%#codegen
% Make dbn.rbm a cell array with each element equal to []
dbn.rbm = repmat({[]}, numel(dims)-1,1);
works fine with:
>> codegen randDBN -args {1:4}

  0 件のコメント

サインインしてコメントする。

カテゴリ

Community Treasure Hunt

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

Start Hunting!

Translated by