1

I am a bit confused about the matlab, sry that I could not find a better title.

I have the following structure

testit.m
+package
   testfile.m

testit.m contains:

import package.testfile

testfile 

testfile.m contains:

view = struct();
v = uiextras.Grid( 'Spacing', 5 );
view.view = v;
view.axes = axes( 'Parent', view.view ); 

If i now cd into the base directory and type testit I get the the following error:

??? Error using ==> axes
Conversion to double from unknown is not possible.

Error in ==> testfile at 4
view.axes = axes( 'Parent', view.view );
Error in ==> testit at 3
testfile 

So far so good. But if I do not put testfile.m into the package and call it directly via testfile.m everything works fine. If I replace the last line of testfile.m with

view.axes = axes( 'Parent', v ); 

such that I don't use the struct to access the Grid, I get the error:

??? No method 'onChildAddedEvent' with matching signature found for class 'uiextras.Grid'.

Error in ==> Container>@(varargin)obj.onChildAddedEvent(varargin{:}) at 95
            obj.Listeners{end+1,1} = handle.listener( containerObj, 'ObjectChildAdded', @obj.onChildAddedEvent );

Warning: Error occurred while evaluating listener callback. 
> In testfile at 4
  In testit at 3

uiextras comes from http://www.mathworks.com/matlabcentral/fileexchange/27758

Why does it make a difference wether I put the file into a package or not? Why does it make a difference wether I use v or view.view? Do I just misunderstand the matlab syntax?

3
  • why was this question being voted for closing down .. without even a single comment? Commented Dec 13, 2012 at 7:55
  • 1
    One thing that I can think of that can cause different behavior if you call things in different way is the presence of functions or variables. Just to be sure: does testfile.m also work fine if you do a clear all before you call it? Commented Dec 13, 2012 at 9:35
  • Thank you. That was part of the solution. Together with the fact that matlab does not recognized that a file was moved, so that the file was still saved to the package when I intended to move it out (normally OSX Application notice when a file is moved and just save it to the new location instead of re-creating it at the old one, as matlab did). That caused some confusion. Commented Dec 16, 2012 at 12:44

1 Answer 1

1

This is not an answer per se, but might be useful to others who ended up at this post like me. Some files on the Matlab File Exchange include a version and/or parts of the GUI Layout Toolbox (+uiextras) within themselves. You can run into problems when you have one instance of +uiextras inside one of these other File Exchange downloads in your path in addition to the "real" instance of GUI Layout Toolbox (+uiextras) downloaded directly from its own entry in the File Exchange.

I was getting these kind of error as Ferio above when filling standard layouts in +uiextras with axes/buttons/uitables/etc:

Error in ==> Container>@(varargin)obj.onChildAddedEvent(varargin{:}) at 95
        obj.Listeners{end+1,1} = handle.listener( containerObj, 'ObjectChildAdded', @obj.onChildAddedEvent );

It turned out that there was another instance of +uiextras in my path inside of a random File Exchange download that I had tested out a while ago, but no longer use. I deleted the entire folder for the other File Exchange download (in retrospect, removing from path probably would have been sufficient), and now things work fine with GUI Layout Toolbox.

You can find out if this is the same problem you're having by following the error links. Do something with uiextras that gets you the error. Click on the link to the line number of the error (line 95 in this case), it will open up the file where the error happened. For me, that file was inside of a DIFFERENT +uiextras folder that was inside of this random other File Exchange download. I deleted that folder, and that solved my problem.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.