Info

This question is closed. Reopen it to edit or answer.

Error only in 2012 version

2 views (last 30 days)
Rebecca Somach
Rebecca Somach on 18 Jun 2019
Closed: MATLAB Answer Bot on 20 Aug 2021
I'm trying to use some code to play a video but I keep hitting an error. The error says "Attempt to reference field of non-structure array"
while ishandle(hFig) && ~bKillAll
set(hText,'String',['frame ' num2str(fr) '/' num2str(macroDat.nofFrames) ' target FPS: ' num2str(curTargetFrameRate)]);
switch behavior(startFr)
case 0, hText.String = [hText.String ' SLEEPING'];
case 5, hText.String = [hText.String ' EXPLORATION'];
end
and the other place in the code where hText shows up at all is here:
hText = title(axHandle,['frame ' num2str(macroDat.fileReadPointer-1) '/' num2str(macroDat.nofFrames) ' target FPS: ' num2str(macroDat.targetFramerate)]);
However this error does not exist in the 2019 version of Matlab, but we need it to run on our 2012 version. I was told it might have something to do with handles, but I'm not sure about that. Any advice?

Answers (1)

Steven Lord
Steven Lord on 18 Jun 2019
The ability to set property on Handle Graphics objects using the syntax hText.String was introduced in release R2014b as a part of the major graphics system update. For older releases you will need to use the set function to set properties on your Handle Graphics objects. This will work both in releases before the update (release R2012a and R2012b) as well as releases after the update (release R2019a.)

Tags

Community Treasure Hunt

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

Start Hunting!