Matt N.
Matt N.

Reputation: 1239

Attempt to reference field of non-structure array

Can anyone tell me why the following code

function s3()

   function ret = fun(x)
       disp(x);
       ret = 0;
   end

  fun(1);

end

produces "Attempt to reference field of non-structure array.". I have this code in a file called s3.m. If I run this in the editor using the play button it runs fine. If I enter s3.m on the command line it produces the above error. Thanks for any help in advance!

Upvotes: 1

Views: 18844

Answers (1)

Ravinder Singh
Ravinder Singh

Reputation: 300

Call it this way:

s3()

rather than

s3.m

because it's a function you have created.

Upvotes: 5

Related Questions