What is a .tlc file? [duplicate] - matlab

This question already has answers here:
Arduino stepper motor control with Simulink
(3 answers)
Closed 8 years ago.
Hi im quite new in this stuff. I am trying to get an arduino board to run with a stepper motor and Simulink model but when I try to run my Simulink model on the arduino i keep getting an error that says that a .tlc file is missing. ( I am using Matlab R2013a )
My question is can someone explain in a simple way what is this .tlc file where is it used and why ?
And do I need to write one for my program to run.
I have posted in more detail my problem with the arduino in this question.

TLC (Target Language Compiler) files are used to customize the code building process. They generally come in two varieties
System/model tlc files that help in the overall model conversion process
Block level tlc files which describe how individual blocks (typically S-Functions) get converted to C code.
But writing them is a very advanced maneuver, and describing them in a short answer difficult.
You should search the doc for the term "Introduction to the Target Language Compiler" and read the links from there to get a more detailed overview.
If you're getting an error about a missing tlc file from a package that you didn't author (i.e. Arduino) then you need to go back to the authors of that package and get it.
It's not something that you're going to be able to generate yourself.

Related

Modelica - VoltageController and PWM on a PMSM?

I'm trying to simulate a SMPM with a VoltageController and a PWM in OpenModelica. After looking for old threads on the subject I found this one: PI-Controller doesn't reach reference value with inverter and PMSM in Modelica
Basically, that's exactly what I'm looking for. However, after copying #marco 's code and pasting it into Modelica, I have an error as seen in the attached image.
The PWM block is not displayed here. and the VoltageToDutyCycle block is missing a connection.
Can someone help me what's going on there, or even send me an executable version?
Maybe I'm doing something wrong, since I'm still a beginner at Modelica I don't want to rule that out ;)
I corrected the answer, it should work now.
Keep in mind, that this code was written with Modelica Standard Library (MSL) 3.2.3. The current version is 4.0.0. Either use the old MSL or
convert to the new version.
The missing MySignalPWM block was just the original block from the MSL. The class path is fixed now.
Regarding the connection: there is nothing missing. The third boolean input is disabled, but OpenModelica still displays it. Other Modelica tools are smarter and do not show disabled connectors. The thermal port in the center of this component should also not be visible.

Is Simulink build something like .exe from our model?

In every model which are creating in Simulink are consist of some blocks and wires, I think blocks are shared library in the backend of Matlab, now I would like to know are those wires are shared library like blocks?
another question is:
when we click on the play icon, we can see something in the taskbar which shows, compiling... my question is, Is at this phase Matlab building .exe file that containing those shared libraries?
Yes, you are right, it is compiling and than running the functions for each simulation step, see here. This is efficient since Simulink simulates multiple time steps of the same model and; therefore, it is worth invest a little time into compiling.
You can note the compiling if you use the Matlab-Code function block, where you need to activate code-generation. Nevertheless, you need the Code Generation Toolbox to divert the model as an .exe.

Converting SBML model into a simulatable Matlab Function

I'm looking for a tool to convert a SBML model into a Matlab function. I've tried SBMLTranslate() function from libSBML but this returns a Matlab struct, not a function. Does anybody know if such tool exists? Thanks
There are at least three efforts in this direction:
Frank Bergmann offers an online service for SBML translation where you can upload an SBML file and it will generate a MATLAB file. The comments at the top of the generated MATLAB file explain how to use the results. The C++ source code is available on SourceForge.
Bergmann's code referenced above was used by Stanley Gu to create sbml2matlab, a Windows standalone program. Off-hand, I don't know whether Gu's version changed or enhanced the algorithm used by the Bergmann version, but it seems likely. (Note: Gu now works at Google and does not maintain this code anymore, as far as I know.)
The Systems Biology Format Converter (SBFC) is a framework written principally by Nicolas Rodriguez; it includes a collection of converters, one of which is an SBML-to-MATLAB converter. This converter is written in Java.
I have not compared the results of the translators myself yet, so cannot speak to the differences or quality of output. If you try them and have any feedback to relate, please let the authors know. Knowing what has or hasn't worked for real users will help improve things in the future.
A final caveat is that all of these have been research projects, so make sure to set your expectations accordingly. (This is not a criticism of the authors; the authors are very good – I know most of them personally – but the reality of academic development work is that we all lack the time and resources to make these systems comprehensive, hardened, polished, and documented to the degree that we wish we could.)

random forest code review

I'm doing a research project on random forest algorithm. I have found numerous implementations of the algorithm but the main part of the code is often written in Fortran while I'm completely naive in it.
I have to edit the code, change the main parameters (like tree depth, num of feature variables, ...) and trace the algorithm's performance during each run.
Currently I'm using "Windows-Precompiled-RF_MexStandalone-v0.02-". The train and predict functions are matlab mex files and can not be opened or edited. Can anyone give me a piece of advice on what to do or is there a valid and completely matlab-based version of random forests.
I've read the randomforest-matlab carefully. The main training part unfortunately is a dll file. Through reading more, most of my wonders is now resolved. My question mainly was how to run several trees simultaneously.
Have you taken a look at these libraries?
Stochastic Bosque
randomforest-matlab
If you're doing a research project on it, the best thing is probably to implement the individual tree training yourself in C and then write Mex wrappers. I'd start with an ID3 tree (before attempting C4.5 for instance.) Then write the random forest code itself, which, once you write the tree code, isn't all that hard.
You'll:
learn a lot
be able to modify them as much as you like
eventually move on to exploring new areas with them
I've implemented them myself from scratch so I can help once you post some of your own code. But I don't think anybody on this site will write the code for you.
Will it take effort? Yes. Will you come out of it with more knowledge and ability than you had going in? Undoubtably.
There is a nice library in R called randomForest. It is based on the original implementation of Breiman in Fortran but it is now mainly recoded in C.
http://cran.r-project.org/web/packages/randomForest/index.html
The main parameters you talk about (tree depth, number of features to be tested, ...) are directly available.
Another library I would recommend is Weka. It is java based and lucid.Performance is slightly off though compared to R. The source code can be downloaded from http://www.cs.waikato.ac.nz/ml/weka/

How to invoke a matlab function from mathematica?

I would like to call a matlab function from mathematica. How best to do that?
I have found an ancient post on Wolfram site describing a way to do this, is this still the way to connect the two?
You can try NETLink for this at least under Windows:
In[1]:= Needs["NETLink`"]
matlab = CreateCOMObject["matlab.application"]
Out[2]= «NETObject[COMInterface[MLApp.DIMLApp]]»
And then you can invoke Matlab functions:
In[4]:= matlab#Execute["version"]
Out[4]= "
ans =
7.9.0.529 (R2009b)
"
In[5]:= matlab#Execute["a=2"]
matlab#Execute["a*2"]
Out[5]= "
a =
2
"
Out[6]= "
ans =
4
"
HTH
You can use mEngine. The precompiled Windows MathLink executable works with Mathematica 8. On Windows you may need to add MATLAB to the system path.
The advantage of this compared to the NETLink method is that transferring variables between Mathematica and MATLAB will be as easy as mGet["x"] or mPut["x"]. Although this might be possible with NETLink too, the advantage of mEngine is that you don't need to implement it yourself (which is great if like me you don't know anything about COM or .NET)
I would imagine that this is a difficult problem in general, but can be easily solved with a little programming for a particular case. I'll demonstrate with C#.
I would build a string of calls, like so.
Mathematica calls a C# program, through MathLink. This is near trivial to setup, and Mathematica has a sample project in Mathematica\8.0\SystemFiles\Links\NETLink directory.
C# program calls Matlab. There are several ways to make this call, and this handy link describes how to do it and offers sample code.
C# program returns Matlab results.
All in all I could do this in less than 50 lines of C# code, for a specific problem. Not too much work, in other words. Possible problems are data conversion, but if you want to send back and forth arrays of data, MathLink offers a lot out of the box. Similarly Mathematica can be linked to MATLAB through Java, though I haven't done that myself.
Perhaps the easiest connection could be made through Python. Mathematica offers an installable MathLink python library, located at Mathematica\8.0\SystemFiles\Links\NETLink, and Matlab has an addon library called PyMat, which can be downloaded here, but this package hasn't been maintained for a long time and supports only the most ancient of Matlabs.
Alternatively you can forgo Matlab altogether in favor of SAGE and/or numpy.
There is now a new package for this --- MATLink. It is the most complete such package I am aware of. (Disclaimer: I'm one of the developers of MATLink.)
MATLink lets you ...
seamlessly call MATLAB functions form Mathematica
transfer data between the two systems
Most MATLAB data types are supported, including sparse arrays, structs and cells.
A more complete description is available here. For detailed examples, see the website.