Hi I hope this question conforms to community guidelines. While working in Matlab I'd really appreciate if the command window had tabs (much like most terminal emulators in Linux). Is available in Matlab or do I have to run different instances of Matlab?
I am running a system which produces plots so running Matlab in text based mode via -nojvm is not possible.
EDIT: Is there a way to get such a feature or do I have to wait for Mathworks to wake up and implement this simple, timesaving tool.
Hmm I think the way Matlab works (with the workspace and the editor) tabs might not be that beneficial in terms of performance as opposed to just running a new instance of Matlab.
In Linux, you can fork new MATLAB instances with unix command and pass the MATLAB command you want to run as a command line argument. If you add & to the end of the unix input string, the new MATLAB instance becomes a background process, so this way from one MATLAB command window you can run commands (with output) in several MATLAB instances, opening a new MATLAB instance for command execution and output.
Here's the code:
multithread.m:
function multithread(MatlabCommand)
% this is a function to create a new MATLAB instance and run a command in it.
unix([ 'matlab -desktop -r ', MatlabCommand, ' &' ]);
return
testfunction.m:
function testfunction()
fprintf('one two three.\n');
return
Then you can run MATLAB commands in a new instance this way: multithread('testfunction');.
As far as I know, there is no such feature.
Although are you aware that you can use the -nodesktop flag to run Matlab in the current console and still have the ability to bring up plots?
Well - depends on what you plan to do with the tabs. You do have tabs for file editor, variable editor. But I suppose you mean command window.
I sometimes have two or more instances of Matlab open - one doing some calculation and doing some observation and quick stuff from the other - but I don't find it advisable.
I have found against using multiple instances that the preferences and path get "unusable" regularly (say once every month).
But as Matlab is "single" threaded - while it's calculating it's near impossible to do simple tasks as editing code or open a file in the same instance. If it had tabs i imagine it even worse. I think this problems lie very deep inside how Matlab works so that will not change very soon.
Related
I am currently running a python3 script in Ubuntu server 18.04. When i type new commands into the command line it just prints the commands. My terminal window looks like this:
mitch#server:`$ cd /home/mitch/folder
mitch#server:`/folder$ python3 main.py
file running ...
text i input just shows like this
I need to keep the script running and run other commands, how do i navigate back to:
mitch#server:`
I'm new to servers/Ubuntu/commands so this may seem trivial! Thank you
So you can't "navigate" back to that, since you're technically already there, you're just running a script in your shell which is occupying your shell - think of it like you opened a program in full screen.
But you have a few options:
The most basic is to run the script in the 'background' this is a simple as adding a & to the end of your command (note that it will still send any message from the script into your terminal - if your script is programmed to send messages that is).
Another option is to use a terminal multiplex like which lets you have multiple terminals open, as well as split screen terminals and many other features. One of the more popular multiplexers is called tmux, just keep in mind that it does have a bit of a learning curve to it, but is extremely useful once you learn it.
I need to automate the act of printing .xlsx file.
I have already seen some answers to this task saying that it is possible by creating a VBA script, as well as some examples. That is not about what my question revolves around.
Thought, I know that it is also possible to right-click on a .xlsx file and click "Print", which does the exact task that I want. It opens Excel, prints the file to the default printer, then closes Excel. (Windows 7, by the way)
So I'm thinking that the work has already been done here.
What process is launched when clicking this "Print" option? Can it be launched via command line, or "clicked" by a python script or something? And if not, why? How can something so easy to click be impossible to automate? I assume a process of some sort must be launched in some way.
Found it!
This task can be easily launched using python.
import os
os.startfile('C:/path/to/the/file.xlsx','print')
This code will launch the same print task. From there, it is pretty trivial for a python developer to automate the task in his scripts.
However, if you do not know much about Python and do not want to learn it now, an easy (or lazy?) way to add it in any automation script would be to save the two lines of code above in a whatever.py file, and launch it via command line (with Python installed, of course).
The context menu print command for Office documents utilizes Dynamic Data Exchange (DDE) and does not directly run a command that can be replicated from the command line.
You can view the content of the commands in the registry. Browse to HKEY_CLASSES_ROOT\.xlsx and look at the (Default) data column. On my machine, "Excel.Sheet.12" is the type of a .xslx file. Then browse to HKEY_CLASSES_ROOT\Excel.Sheet.12\shell\ to see the commands registered for that file type. On my machine, the Print (Default) is "C:\Program Files\Microsoft Office\Office16\EXCEL.EXE" /dde and the "command" is zn=BV5!!!!4!!!!MKKSkEXCELFiles>]-z5hw$l[8QeZZR4_X=$ /dde, none of which is directly useful or accessible for running from a command line.
It will require another program to allow you to access the interface, but there are programs that allow you to make use of DDE from the command line. I recommend Freddy Vulto's Class Exec. More information and a few other similar utilities can be found here.
Using the Turtle shell scripting library I am trying to launch a program, i.e:
shell "vim" empty
The problem is that this yields the warning Warning: Input is not from a terminal and causes Vim to lag for a few seconds before finally launching.
Questions:
Is shell the best Turtle function to launch an external program from haskell?
If so, is there any way to get around errors like the above?
You want to use functions from the process library, specifically createProcess or runProcess.
Relevant turtle thread on the issue here.
Example usage.
You could try manually setting up I/O to the vty. E.g. in bash: vim < $TTY > $TTY. I guess turtle is doing that with its own file descriptors under the hood, based on the warning, so you should be able to manually set up those redirects (or just use the command I gave via shell). You just need to make sure you've got a TTY environment var around.
I am trying to fully automate my simulation scripting under Linux. Currently, I manually click open a terminal, enter the commands to get the simulation running, click open another terminal, and do the similar things.
What I have done so far is having multiple shell scripts, each of which opens one terminal and does the stuff. Despite having little experience with shell script, I believe this can be automated with one single shell script.
How may I open multiple terminal windows and do different stuff in those terminals from one single shell script?
If you want to execute your commands/scripts in sequence, just write them in a file, each per line, then bash theFile
if you want to start/run a number of job in parallel, you may want to check this out: http://www.gnu.org/software/parallel/
If you want to start/run commands in different terminal but you don't want to manually "click". tmux/screen would be your friend. with tmux, you can define when it starts, open how many windows/panes, and in each window/pane which command should be fired.
tmux link: http://tmux.sourceforge.net
P.S. tmux is very handy tool, I work everyday with it. It is must-have tool 4 me.
I have a program that needs to start another program. On my mac I did this using system("open path"), but on linux that doesn't work. and using system(./path) is not what I want since than it overtakes the running program.
So is there any way to get the same behaviour as the mac 'open path' command on linux?
(linux noob btw:p)
If you're running the application in a GUI environment, this should be possible but the approach is different. You need to start a new terminal instance explicitly.
Determine the path to your terminal application. This depends on the linux distribution.
Next, check the documentation of that particular terminal application and find out how it can be started to run an application (your application) instead of a shell. This probably involves using some application-specific command line options. Test that in a terminal window, until you have a command line that gives you the desired result. Things could get a little tricky if your application needs command line arguments as well. Use the -- option where necessary.
Then, all you need to do is run that command line from your "parent" application. I would advise however to not use system(). The exec... family functions (using fork and wait) provide better control.