Dot name reference on non-scalar structure using Video Reader class

조회 수: 7 (최근 30일)
Townsend
Townsend 2012년 9월 24일
댓글: Falak Shah 2014년 3월 19일
Hi... I am trying to read in a .wmv. I have basically copied the example from the VideoReader class in the help but I get this error when I run the .m:
Dot name reference on non-scalar structure.
Error in VideoReader/read (line 91)
if( ~isempty(obj.NumberOfFrames) )
Error in vidFile (line 22)
mov(i).cdata = read(Test, i);
mov is a 1xNumberOfFrames struct with objects 'cdata' and 'colormap'. The main issue is number frames it reads before this error is thrown varies.
Please help. I have banged my head against the wall enough...

답변 (1개)

Ralph Hummeling
Ralph Hummeling 2012년 9월 25일
편집: Ralph Hummeling 2012년 9월 25일
@Townsend:
I'm afraid you've stumbled upon a bug that persists since R2012a. Matlab sometimes erroneously interprets a scalar structure as being non-scalar when confronted with a getfield operation: S.fieldname
A workaround is to insert an index on the field reference like this: S(1).fieldname
It's ugly but it works. So in your case your code could read: if( ~isempty(obj(1).NumberOfFrames) )
  댓글 수: 9
Falak Shah
Falak Shah 2014년 3월 19일
Having a similar problem in 2012b.. Tried editing as suggested too.. doesn't work... Kindly suggest some solution..

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

카테고리

Help CenterFile Exchange에서 Timing and presenting 2D and 3D stimuli에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by