필터 지우기
필터 지우기

Variable size arrays for code generation

조회 수: 2 (최근 30일)
Matthias Kreuzer
Matthias Kreuzer 2023년 1월 10일
답변: Mark McBroom 2023년 1월 14일
Hey,
I am trying to generate c++ code with matlab coder and encounter a problem. I have implemented a CNN from scratch and thus my output variable 'a' changes its size after every layer/after every call of process_layer:
a = process_layer(a, layer).
Even though I declared coder.varsize('a') beforehand I get the error message: ' ?? Left hand side of the assignment has fewer dimensions than the right hand side: [:? x :?] cannot be assigned from [:? x :? x:?]. It seems like the coder expects the number of elements in each dimensions to change but not the number of dimensions. For example 'a' can be be two-dimensional and the output of process_layer is three-dimensional.
Can you help?

답변 (1개)

Mark McBroom
Mark McBroom 2023년 1월 14일
Try first declaring a to be a 3-D matrix before declaring varsize:
a = zeros(2,2,2);
coder.varsize('a')
a= process_layer(a,layer)

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by