How do I launch a matlab gui from the desktop?

168 ビュー (過去 30 日間)
fichtorious
fichtorious 2013 年 2 月 8 日
コメント済み: Jan 2017 年 6 月 19 日
I have a GUI that a I developed mygui.fig that calls mygui.m as per usual. I tried copying mygui.fig to the desktop to see if it would run that way, but it only brings up the figure and doesn't make the connection with the code in the .m file.
Is there a way, through matlab, that I can one click launch my gui from my desktop?
If not, I was considering writing a script to launch it but am not sure if there is a protocol to launch matlab then execute a command via an .exe
If anyone can help I'd be greatly appreciative.
  1 件のコメント
Tadgh
Tadgh 2014 年 2 月 10 日
Would it be possible for you to help me create a shortcut that i can double click to run my model without opening the script file? I've been trying to do this in the GUI interface for weeks but can't figure it out........
Would really appreciate any help

サインインしてコメントする。

採用された回答

Jan
Jan 2013 年 2 月 12 日
You can create a batch file, which contains:
matlab -nosplash -r yourMFile
This starts the M-function, which automatically opens the FIG file.
  6 件のコメント
Mandeguz
Mandeguz 2017 年 6 月 15 日
編集済み: Mandeguz 2017 年 6 月 15 日
So how can you change the path in the bat file? When I open my gui, I have to change the directory, and I'd like to keep my files there (I don't have permissions to save where the directory initially opens, so I always have to change my path).
Jan
Jan 2017 年 6 月 19 日
@Mandeguz: Do you mean:
matlab -nosplash -r "cd('C:\Your\Path'); yourMFile"
?

サインインしてコメントする。

その他の回答 (3 件)

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 2 月 8 日
編集済み: Azzi Abdelmalek 2013 年 2 月 8 日
If you have a Matlab compiler toolbox, create an executable which could be lunched from your desktop
doc deploytool
  1 件のコメント
fichtorious
fichtorious 2013 年 2 月 12 日
Yeah I don't have matlab compiler which is the problem.

サインインしてコメントする。


Malcolm Lidierth
Malcolm Lidierth 2013 年 2 月 12 日
One way might be to launch a Java executable and connect to the MATLAB engine using the Java Matlab Interface via matlabcontrol:
If your GUI were Java-based (as opposed to MATLAB/Java-based) you could choose another engine, e.g. SciLab, R etc.
  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.

サインインしてコメントする。


Ryan Livingston
Ryan Livingston 2013 年 2 月 12 日
Not too certain on the question. If you want to launch the GUI with a click (or two) from MATLAB just right-click the M file in the folder browser and pick "Run".
If you want to run the GUI by double-clicking something from the desktop (in Windows without MATLAB open) you can make a file "runGui.bat" which contains:
start matlab -r mygui
Then you can double-click that to launch MATLAB and open the GUI. Note that this assumes you have MATLAB on the system path and that "mygui.m" is in the same directory as "runGui.bat".
  1 件のコメント
fichtorious
fichtorious 2013 年 2 月 12 日
So I tried this my exact code in the batch file was:
start matlab -r FrequencyResponseGUI.m
It simply brings up matlab but doesn't start the GUI. I put the batch file in my matlab work folder which is where my .m file is located and then created a shortcut to set on the desktop so I could run it from there. Any reason why it would only bring up matlab and not start the GUI?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSearch Path についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by