What is the usual way in MATLAB to read help page by page? - matlab

I'm looking for an equivalent of for example DOS's dir |more which lists the data, until one page is complete, then waits for a key to be pressed until showing another. Is there an equivalent for MATLAB's help system.
I know I could simply scroll back, but this would be so much more convenient, expecially if one uses help system often.

Type more on at the command line. This will print command outputs page by page.
For the next line: 'return'; next page; 'spacebar'; return to command line: 'q'.
Likewise, more off resumes the normal display mode.

Related

waitbar matlab before start a standalone script

I did a standalone application in Matlab and it works. The only problem is that when I launch the application, it takes time before start asking to the user some file (it is the first think the program has to do). The user does not understand if the program is working or not, since no message neither symbol of working progress appear on the screen.
My idea is to show a waitbar until the window asking the file to user appears.
How can I do this? is it possible to use the waitbar outside a loop?
The script starts as follow:
close all
clear all
[filename,pathname] = uigetfile({'*.xlsx'},'Opening File','C:\');
I don't know why, it takes time before open the window for choosing the file.
The time between launch and file selection input appearing is most likely due to the time it takes to load the MCR. You could add a splash screen to your compilation.
If the end user is running from a command line wrap your exe in a system/shell which writes to the command window that the application is starting.
Your issue is most likely the use of clear all. This makes MATLAB remove all variables (in scope, global and persistent), and compiled scripts from memory, forcing it to recompile and load everything again.
If your purpose is to clear all variables in the current scope, you should be able to increase the initial speed of your script by only running clear instead.
Even faster speed can be achieved if you specify which variables to clear using clear var1 var2 ...

How can I issue carriage returns after a system call in MATLAB?

Context: In a large program built mostly in MATLAB, I am calling a program to display some information to the user, like so:
batchCommand = ['"', programPath, '" ', '"', inputPath, '"'];
system(batchCommand);
Here's the issue: the program at programPath opens two consecutive splash screens, which require the user to press enter in order to bypass. That really busts up the flow of my program, and I'd like to do away with it. There is no option to run the program without the splash screens. The splash screens are in-focus, so pressing return clears them with no further input. So, I'd like to have MATLAB issue a couple of carriage returns for me.
Here's the catch: the system command halts execution of MATLAB code until the opened program is closed. I need to work around this in some way to get those returns issued.
I've tried working with -echo, to no avail.
Has anyone out there done this, or know how to?

Powershell commands?

Ok I'm having trouble and google isn't helping, so I thought I'd come to you geniuses. I'm using Powershell and posh-git, and it keeps doing something that I'm sure I can exit out of with a magic command, I just don't know it yet.
Basically, when I run git diff (or something else with a long result), it will only give me a screen's worth of information, and end the screen with a colon
:
And if I keep pressing Enter it will add more to the screen til it is done showing everything for that command, and shows
<END>
But now what? How do I get out of this and back to calling commands? Enter, Esc and the other things I thought to try are not helping. I'm sure this must be a simple thing, but I don't know how to explain to Google what I want.
Anyone know?
if you do a git config -l you may see some relevant entries like:
core.pager='less'
pager.diff=false
pager.log=true
You can enable or disable the pager for different commands, or set a different pager. https://www.kernel.org/pub/software/scm/git/docs/git-config.html has the details, check out the core.pager section and pager.<cmd> sections for specifics.
If you're using 'less' as your pager, hit 'h' at that : prompt to get lots of details about what you can do there, and as pointed out by others, q, Q, or ZZ will get you back to the command line.
You can terminate the current command using CTRL+C. Is that what you're asking?

Matlab clc command

I was checking the original 'clc.m' file in MATLAB. Apparently the function is written as a p-code and you just see the description which is placed in:
..\MATLAB\R2013a\toolbox\matlab\iofun\clc.m
How can I take a look at the original code?; however this is not the main question, it is just for fun.
The main point is I am looking for a way to reverse the clc process, after you clean the screen. Is there any way to reverse the clc process. The same question goes for clear all as well.
Try using home instead of clc. Whereas clc removes all text from the Command Window and moves the cursor to the top left giving you a blank window, home just moves the cursor to the top left and gives a you a blank window - but the text is still there, and you can scroll up to see it. I use home all the time rather than clc.
In either case, the text remains in the Command History window, and can be retrieved in the Command Window using the Up/Down arrows.
The reason you can't see the code behind clc is not that it's p-coded, it's that it's a built-in function (i.e. not implemented in the MATLAB language). The same is true for clear, and also many math functions such as svd, eig etc. There's no way to modify them to change what they do (such as reversing the process).
Edit: You might also like to look into the diary function, which keeps a log of all the input and output at the command window in a specified file. I have the following lines in my startup.m file (type doc startup if you don't know how to use MATLAB startup files):
diaryFolder = 'C:\diaries';
diaryFileName = ['diary', datestr(now, 'yyyymmdd'), '.txt'];
diary(fullfile(diaryFolder, diaryFileName))
So whenever I start MATLAB, it's automatically capturing all command window input and output to a diary file that's named by the date - If I start MATLAB multiple times a day, it just appends to the same file. I can clc or home whenever convenient, and there's always a record kept of everything that I can search through if necessary.
I don't believe there would be anyway to undo the clc process. That said, it is possible to still view the command history, so that might get you somewhere.
Once you clear the data, I believe it's gone forever. I highly doubt that data is stored in memory somewhere. I know that after a certain number of lines, the history is deleted. So your best bet is to start figuring out how large that buffer is and proceed from there to see if you can find anything interesting.

Disable auto-scrolling in command window

A lot of the code that I write in Matlab has a very verbose output. As the program runs, information is printed to the command window, and with each new line, the window automatically scrolls to the bottom. This becomes a problem when I want to read some of the output more closely or scroll up to look at older output. I can scroll up, but only until a new line is printed, which is often less than a second.
Does anyone know if it is possible to turn off this automatic scrolling in the Matlab window? I work in a number of different Matlab versions, depending on the machine, and this happens with all of them. The answer to this might be "No", but I swear I remember having this functionality at one point.
Use the more function: http://www.mathworks.com/help/matlab/ref/more.html
more on
Then run your program. Press spacebar when you wish to see more of the output.
more off will turn it off.
You may find this workaround useful.
First launch matlab using the command line matlab -logfile 'myLog.txt' (the doc says it "starts MATLAB and makes a copy of any output to the Command Window in filename. This includes all crash reports.")
Then open your .txt file using a text editor supporting automatic refresh of content (see picture). On OSX I use TextWrangler (freely available at www) but others have been reported to have this feature (see here or here).
Results: output displays (fprintf, disp, but not the commands per se) are printed both on the Matlab console and the text editor (file is refreshed with a little lag time, below half a second I would say with my configuration). And there is no automatic scrolling. Such procedure does not seem to impact the overall performance of the script (although it may deserve some testing).