Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined methods for MxArrays.MxArray type #55

Open
agbondy opened this issue Sep 22, 2017 · 3 comments
Open

undefined methods for MxArrays.MxArray type #55

agbondy opened this issue Sep 22, 2017 · 3 comments

Comments

@agbondy
Copy link

agbondy commented Sep 22, 2017

I'm using mexjulia to call a julia function "compute_LL.jl" from matlab which takes a dict as an input. I'm passing it a Matlab struct, which gets converted sensibly to a dict but its fields, which are just arrays of doubles and logicals, get converted into MxArrays.MxArray which somehow no methods seem to be defined for. I think this type should inherit all the functionality of MATLAB.MxArray types but basic methods which are defined for those (I've tried length, subscript indexing) throw an "undefined method" error. I'm using Julia 0.6 and Matlab R2017a on a PC running Windows 10. I'm attaching the Julia module "DriftDiffusison" which contains the function compute_LL which I am calling.

When I call this function, I get: "MethodError: no method matching length(::MxArrays.MxArray)" on line 29 of the module.

The struct getting passed to this function looks like:

struct with fields:

   pokedR: [7487×1 logical]
 leftbups: {7487×1 cell}
rightbups: {7487×1 cell}
        T: [7487×1 double]

DriftDiffusion.zip

@agbondy
Copy link
Author

agbondy commented Mar 9, 2018

OK, I'm still new to Julia but I think I have a better understanding of the problem now, and it is (I think) rather simpler than I thought. The problem is just that, currently, there is no functionality in mexjulia for dealing with composite types. IOW, a cell array in Matlab like { [5 6] [7 8] } gets sensibly converted to a julia array, but its elements don't get converted to julia types. They just end up as MxArrays.MxArray types, which Julia doesn't know how to deal with. Structured arrays also end up as MxArrays.MxArray types in Julia, causing problems. It seems like adding this functionality wouldn't be too hard -- mexjulia would just have to call jvalue recursively, each time checking its output to see if it needs to be run again.

@twadleigh
Copy link
Collaborator

That sounds right. Unfortunately I no longer have access to a MATLAB license, so I have no way to test any code tweaks myself.

@agbondy
Copy link
Author

agbondy commented Mar 9, 2018

That's a shame! Working with proprietary software has definite downsides. Now that I've figured this out, I can scrape by as long as I keep my variables simple.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants