matlab cell mode with vim/gvim - matlab

I want to run a cell using vim. however, using what I see here:
How to implement MATLAB-like cell mode in Vim
I get a matlab instance starting, running and then closing. Is it possible to to this like it would be on a real matlab? ie I have a vim on one side and matlab on the other (open all the time), and by a vim command I get the cell to run on the matlab?

Not sure whether this is exactly what you want, but you might want to browse through these answers

Related

jupyter notebook with octave: code cell is plain text by default

I use jupyter notebook with octave kernel and it runs quite fine.
After a while I wondered why highlighting looks so strange.
Then I realized that part of the notebook is detected as python although an octave kernel is running.
Part of the code cells, in fact most are plain text.
Now I found out in the bottom left corner, one can choose.
The language for octave is in fact MATLAB.
This improves appearance very much.
But now I wonder whether I really must switch each cell individually.
I also found autodetect but this never finds MATLAB.

X11 MATLAB Display Figure

I know it's possible to forward any output from a remote machine to a local one by using the X11 forwarding remote tunnelling, so that when you run a MATLAB command it will display all the graphical outputs back to the machine you've connected from.
My question is:
Is there any MATLAB command to just output the figures (e.g., plot,surf,etc.) without displaying any other graphical object (i.e., the main interface)?
In practice, I would like to interact with MATLAB by using the command line (as shown below) and forward back only the figures.
MATLAB cannot display figures without its own figure-GUI, so the answer to your question would be no.
However: there is a workaround: create an invisible figure using f=figure('visible', 'off'), then plot your data, and finally use saveas(f,filename,fileextention). Don't forget to close(f) your figure after saving, to free the RAM. You'll now have a figure in your file directory, which you can display using your favourite visualising tool, which might even be possible through a call to system, although I have never tested that.

Matlab - Transforming my program into a GUI [duplicate]

This question already has answers here:
How can I program a GUI in MATLAB? [closed]
(4 answers)
Closed 6 years ago.
I wrote a code that: imports sequential files containing x- and y- columns, plots the data, fits the peaks using a 4-term gaussian, saves the plots as .png image files and finally exports all the variables into a table (called final). I want this program to be user friendly as non-programmers need to use it. Please let me know if it is possible. I would like to be directed towards the right path. As I do not know where to start.
There are thousands of resources on-line, but they are not specific. I would like to know if it is possible in my case to create a GUI, so I dont fish in an empty pond.
You might consider using "GUIDE" which is Matlab's GUI design environment. It's fairly easy to use. To start simply type:
guide
in the command window. There is a lot of documentation on how to make a gui with guide. I'd wager you could quickly come up with a gui that calls your script, or you could convert your script to a set of functions and call those from the gui.
http://www.mathworks.com/help/matlab/creating_guis/about-the-simple-guide-gui-example.html

How can I check how does a MatLab function work? I want to check the algorithm for dspdata.psd

I am trying to make Power Spectral Density function in Mathematica and seems like MatLab dpsdata.psd works quite well. Now, I want to implement this to Mathematica but I need how it works and its algorithm. How can I check this?
Type edit dspdata.psd in the Matlab shell. You'll see the code, mostly comments, and then a call to initialize. Click on that word and hit F4. You'll then see the code you are looking for.
You can use open dspdata.psd or edit dspdata.psd in the MATLAB Command Window to view the source code. You can also call open initialize, which will bring up the key function in dspdata.psd.
It may help to review MathWorks's reference pages for this function, available here http://www.mathworks.com/help/signal/ref/dspdata.html and here http://www.mathworks.com/help/signal/ref/dspdata.psd.html.

Disable plots in Matlab

I have some programs written in Matlab that I need to run several times for some reasons (debugging, testing with different input, etc...)
But, there are a lot's of graphs that are plotted by the programs and its various functions such that everytime I run the program, I have to wait for all the graphs to be displayed, which is very annoying and time consuming (especially when you are working with a small laptop).
After the program is executed, I close them with a close all.
So my question is:
Is there a way to disable all plots/figures/graphs in Matlab? either in the options, or by executing a certain code like disable plot and enable plot to ensure that no figures are being displayed.
I know that I can just browse the code and comment the plotting part, but I don't want to forget to uncomment.
Try some combination of the two commands:
set(gcf,'Visible','off') % turns current figure "off"
set(0,'DefaultFigureVisible','off'); % all subsequent figures "off"
The second one, if you put it near the beginning of your program, might do the trick for you. Of course, it is still creating the plots, which might be undesirable for computation time and/or RAM issues.
This is a classic reason to avoid Matlab when one can. It fosters bad programming design. To solve this problem correctly, you should create something that lets you "flip a switch" at the highest level of your program and control whether plots show or do not show. Perhaps it even has gradations of the show/don't show option so you can select different types of plots that do/do not show depending on what diagnostics you are running.
Ideally, you'd want this "flip a switch" creation to be a class that has access to visibility and plot functions of other objects. But because interactive object-orientation is so cumbersome in Matlab, it's often not worth the effort to develop such a solution, and most people don't think about this design aspect from the outset of their project.
Matlab would encourage someone to solve this by making flag variables like "isPlotVisible" or something, and creating functions that always accept such flags. I agree this is a bad design.
You could run matlab from the command line with:
matlab -nojvm
but then you don't get the GUI at all. Alternatively, you could write a file 'plot.m':
function h = plot(varargin)
h = [];
end
which doesn't do anything. If this is in the working directory (or somewhere else near the top of the path), then plot will call your function instead of the 'real' plot. You'd need to do the same from any other graphing functions you call.
The closest way I know of 'turning off plotting' would be a folder of such functions that you can add to the path to disable plotting, and remove to enable.
The previous methods are fine, but an easy and good habit to take is to use a "on/off parameter". So basically, at the beginning of your code, you can add something like:
DisplayFigure = 1; %1 = display, 0 = no display
After that, add "if DisplayFigure == 1 ... end" for all your plotting related commands, where the commands should be inside the if statement (the ... above). Hence you won't even compute the plots, which will save you a lot of time and memory. You just have to change the value of the variable "DisplayFigure" to plot or not the figures.