Error using 'getframe' in an embedded Matlab function in a Simulink Model
3 views (last 30 days)
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
mymovie = struct('cdata',uint8(zeros(420,560,3)),'colormap',double());
figure1 = Myhandle0;
if count >0
subplot2 = subplot(1,2,2,'Parent',figure1);
mycdata = mymovie.cdata;
mycdata = uint8(zeros(420,560,3));
Fred Smith on 6 Mar 2013
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?