필터 지우기
필터 지우기

Error using 'getframe' in an embedded Matlab function in a Simulink Model

조회 수: 6 (최근 30일)
Chris
Chris 2013년 3월 6일
편집: Tong Zhao 2021년 9월 10일
I am trying to use 'getframe' in a Matlab function within a Simulink Model. I get the error "Cannot get field colormap from struct colormap. Block Baseband Waterfall Spectrum/MATLAB Function1 (#74) While executing: none "
Now, obviously the 'colormap' field is empty. For some reason when you use 'getframe' within Simulink it is unable to deal with an empty field. Seams to work fine in Matlab. So is this a bug? Is there a way around the problem?
Please see the function code below:
function mycdata = fcn(v,Myhandle0,count)%#codegen
coder.extrinsic('get');
coder.extrinsic('subplot');
coder.extrinsic('getframe');
mymovie = struct('cdata',uint8(zeros(420,560,3)),'colormap',double([]));
figure1 = Myhandle0;
if count >0
subplot2 = subplot(1,2,2,'Parent',figure1);
surf(v,'Parent',subplot2,'LineStyle','none');
mymovie =getframe(figure1);
mycdata = mymovie.cdata;
hold off;
else
mycdata = uint8(zeros(420,560,3));
end
end
  댓글 수: 1
Walter Roberson
Walter Roberson 2013년 3월 6일
It probably will not make any difference, but the official syntax for the struct in MATLAB would be
mymovie = struct('cdata', {uint8(zeros(420,560,3))}, 'colormap', {double([])});
and you could probably use zeros(0,0) instead of double([])

댓글을 달려면 로그인하십시오.

답변 (1개)

Fred Smith
Fred Smith 2013년 3월 6일
I think this is a bug or a limitation depending on what version you are using. Prior to R2012b, empty-fields were not supported by MATLAB Function blocks.
Functionality very similar to this worked fine for me in the latest development version.
What version of MATLAB are you using?
  댓글 수: 2
Chris
Chris 2013년 3월 7일
I am using R2012b (8.0.0.783) linux 64bit, August 22, 2012.
Tong Zhao
Tong Zhao 2021년 9월 10일
편집: Tong Zhao 2021년 9월 10일
I just got myself into similar situations, it seems not easy to get getframe() to work within a MATLAB function block. Some examples would be great.

댓글을 달려면 로그인하십시오.

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by