Create a GUI in Java and calling Matlab scripts from Java

조회 수: 15 (최근 30일)
Nathan
Nathan 2011년 7월 26일
댓글: Ned Twigg 2015년 10월 20일
Hey all,
I currrently have a functioning Matlab script (and a few other scripts that help with it) that uses avifile, addframe and implay to create and then play back a movie of an animation I have made. The animation loops through .mat files that have
I currently have a 2D animation where I use the image function to create a 4x11 set of small boxes, each representing an individual sensor in a larger scheme of sensors implanted in the ground. In the animation, the color of each box corresponds to the scalar value of the acceleration reading for each sensor. I created the animation by using creating an aviobj using the avifile() function, then using a loop to update the color values and the object with a new figure representing the data using addframe(). I save the AVI file, then I play it back with implay() so I can have the play/pause features.
Now, I was thinking of writing some Java code and making a Java program with a GUI that in some user input for a filename/time period for the data to be used (or some user input like that) and then call the appropriate Matlab scripts from Java. How might I make this happen? I read about the matlabcontrol API and was considering that but am looking for other potential ways to handle this. A potential alternative would be to have the animation carried out from Java? Anything helps, thanks in advance
NathanF

채택된 답변

Titus Edelhofer
Titus Edelhofer 2011년 7월 26일
Hi,
there are several points here to clarify: first of all, why not write the GUI in MATLAB? From your description it seems, that it will not be a hyper-fancy-crowded-with-lots-of-complicated-controls type of GUI, which will be easy to implement in MATLAB.
If it "must" be Java, then (from an implementation point of view) using MATLAB Builder JA would be the simplest approach. Other approaches would be to start MATLAB with the "-r" parameter as a batch processing. Deciding between these options depend on whether other people would like to use the GUI+Computation, and if they have MATLAB or not.
Titus

추가 답변 (1개)

Yair Altman
Yair Altman 2011년 8월 7일
You can use the MatlabControl Java package to call Matlab directly from Java without needing the Matlab Builder JA toolbox: http://UndocumentedMatlab.com/blog/jmi-wrapper-remote-matlabcontrol/
  댓글 수: 1
Ned Twigg
Ned Twigg 2015년 10월 20일
matlabcontrol is fantastic, but it hasn't been updated in a couple years.
I've created a binary-compatible fork on GitHub which is actively maintained called MatConsoleCtl.
Relative to matlabcontrol, it contains these changes
  • available on Maven Central as com.diffplug.matsim:matconsolectl
  • a way to connect to an existing MATLAB session by copy-pasting a string of text to the MATLAB console
  • more descriptive error messages in exceptions
  • compatibility with OSGi classloaders
  • fixed all compiler warnings
  • fixed several tricky bugs which were found by FindBugs
I'm happy to accept any GitHub Issues or Pull-Requests, and I'll be keeping it up-to-date and tested.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Text Data Preparation에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by