How to use generic classes in Matlab (MIJ package/Miji) - matlab

does anyone know how to use generic classes in Matlab using the MIJ package?
every time I tried to use a generic class I get an "Undefined class" error, while other classes gave me no problems. In particular I would like to use an instance of the ComplexRealFloatConverter class from the imglib2 library to get the real values of an FFT.
Thanks to all!

Most likely it's a path problem, i.e. you need to add the path to the package for example with javaaddpath().
For an extensive explanation on how to do that, please read Bringing Java Classes into MATLAB Workspace. The explanation contains how to make entire packages available.

Related

How to show the whole problem (LP/MILP, SCIP)

How to show the whole LP/MILP problem.
I am using solver(MPSolver::CreateSolver("SCIP")) in c++.
I saw this issue and this reply. However, those are not helpful for SCIP.
Any help?
There are two approaches:
Option A: get the underlying solver, use the scip solver to export the model.
in, details: use the underlying_solver method on the LinearSolver class.
Then cast the returned pointer to SCIP* (see the implementation of this method for the SCIP solver).
Now you have the solver, you can use the solver's API for anything including exporting the model. The only limitation is that you need the solver to have loaded the model, which only happens at solve time.
Option B:
call one the two export methods. This API is also available in non C++ languages.

Redeclare struct in two Swift packages

I created two different Swift packages that I use in several projects. Now I have to use both in the same project and my problem is, that I have a declared struct in both packages, that has exactly the same content and same name. But the compiler complains about that. Is there a possibility to tell the compiler, that these types are equal? I tried to use typealias, but then the compiler complains that he doesn't know where to look for the struct.
Like #matt and #Larme mentioned there are several possible solutions for your problem.
Swift is a module based language, hence you can use #Larme simple solution and differentiate the structs by using the package/module name as a prefix when importing.
According to my opinion #matt and #Larme latter suggestions are more to the point.
If you have two or more packages that are sharing the samr code. Why not creating a third package with that shared code and using it in both? A simple solution to your case would be a Models package where you can have the struct define there, import and use it in Package1 and Package2.

code generation using Treehugger scala

I am using TreeHugger to generate code at runtime. I could not find many documents related to it. My question is, if I generate classes using treehugger, will I be able to access those classes in future?
To be precise: I want to read data coming from files like CSV and create classes at runtime . Can I use that class in future, say in the next class generated at runtime.
I am really new to scala, please forgive if I am not clear in explaining.
Thanks a lot!
I've done something similar, so I'll share what I've learned:
Treehugger ultimately generates code (strings) at runtime to be used in a subsequent, separate run (or I suppose to be eval'd at runtime, but I never got that to work).
So the course of action depends on what you mean by "runtime":
Are your .csv files only available at runtime? If you have access to the files at compile time (as is often the case), then are examples of your two options: experimental (scala macros) or traditional (sbt plugin) -- both approaches are similar but have subtle pros and cons.
If you only have access to the files at runtime, but still need to generate and "type" the classes and make the compiler expect them, then it seems to me that somebody has made a bad design mistake! But if you find yourself stuck in this circumstance, then it is possible to define and load classes at runtime with a bytecode-engineering library and some type-checker black magic (runtime type provider).

How to access an array of structs in simulink?

I have the problem, that I have to access a funktion form a dll in matlab/Simulink in the rtw.
This should work with a s function, but I have the needed parameters in a array of structures organized.
The question is now how I can reach them when I want to call my DLL function?
Or is there a better way (e.g. level 2 Matlab files or something similar)?
The pure simulation (without RTW) worked pretty well with level 2 m files but I am not able to write a tlc file for compiling them. I did not find much on the net and the documentation only about C sources.
Thanks
Christian
For signals in Simulink, what you are asking for is an array of buses. There is similar support for using arrays of structs for parameters. For calling an external function, you might want to look at the legacy code tool. You might also be able to use the MATLAB function block to call your external dll.
In addition to what #MikeT says:
Generating code from Level 2 M-S-Functions is problematic. Read this: http://www.mathworks.co.uk/help/toolbox/simulink/sfg/f7-67622.html#brgscav-1
Also, M-S-functions are generally slow, because they run in the MATLAB interpreter: http://blogs.mathworks.com/seth/2010/10/28/tips-for-simulation-performance/
In the end I coded the problem in C and used an array where I defined to order of the elements. Then I wrote some interface functions to access this "virtual" struct.
This is not very good coding but the easiest way I have found and it is portable.
Thanks

Duplicate class names in different libraries

I am facing an issue where I am getting a compile time error which says duplicate symbol _OBJC_CLASS_$_XYZ in lib1 and lib 2. Looks like the class name is same in both the libs.
How to get rid of this situation? Any clue.
Simple: Change the name of one of the classes. (No, this really isn't simple as you have to change every usage of that class name in the library). Since objective-c is a dynamic language, there cannot be two classes with the same name. Classes are used at runtime to determine everything about the objects you create. To avoid naming conflicts, you should always use prefixes when creating shared libraries.
See Code Naming Basics, specifically the "Class and Protocol Names" section.
Looks like you must rename one of them or have only one loaded at any given time.
What is the best way to solve an Objective-C namespace collision?