preallocation of structure array for MATLAB coder

조회 수: 2 (최근 30일)
JangHo Cho
JangHo Cho 2015년 8월 24일
답변: JangHo Cho 2015년 8월 24일
Hi, I'm using MATLAB coder to convert my image processing routine in MATLAB.
I read several articles here about structure array preallocation.
Here is my MATLAB code snippet. im1, im2 have size of 480 x 640 x 128.
ptemp.im1 = im1;
ptemp.im2 = im2;
[sx, sy, sz] = size(im1);
picturesque(1:nlevels) = struct('im1',zeros(sx,sy,sz),'im2', zeros(sx,sy,sz));
picturesque(1) = ptemp;
But the MATLAB coder tells me picturesque is not defined.
Undefined function or variable 'picturesque'. The first assignment to a local variable determines its class.
I tried many times, changing preallocation methods. But I didn't find any clue.
Do you have a good solution to preallocate the structure array for MATLAB coder?

채택된 답변

Sean de Wolski
Sean de Wolski 2015년 8월 24일
picturesque = struct('im1',zeros(sx,sy,sz),'im2', zeros(sx,sy,sz));
picturesque = repmat(picturesque,1,nlevels)
Perhaps?

추가 답변 (1개)

JangHo Cho
JangHo Cho 2015년 8월 24일
Thank you. It works! That's what I wanted. :)

카테고리

Help CenterFile Exchange에서 MATLAB Coder에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by