Why is my workspace window empty (while I can see my variables with "whos")? - matlab

So I am having this problem for a few days now.
I am using Matlab R2017b on Mac, and it worked perfectly up untill a few days ago when I ran a code (not for the first time) and my variables did not appear in the workspace window. However I can see them all when using the command "whos".
I was running very simple scripts to create graphs and perform stats.
I have no idea if it is related, I wouldn't think so but just in case, it happened when I ran the code and also got that warning:
"Cleaning up unclosed ZipFile for archive
/Users/.../CD_EBCC_data.xlsx"
I've rebooted the computer but no changes.
Thanks in advance for your help! Let me know if any extra info could be of help.
EDIT:
Here a screenshot:
on the left are all my variables as visualized with "whos", on the right you can see the empty workspace.
If I type "a=1" in the command window, there is no variable a created in the workspace but if I type whos I can see it is actually there. It is just that I cannot see it in the workspace window. If I type the name of an existing variable, it is displayed normaly in the command window. Hope that is clearer.

Related

How to get rid of the commands bringed by VS code terminal over and over

I have no idea why, but my VS code terminal keeps bringing in the history the same commands that I have used one day. So, every time I open the VS code, instead of bringing me the last used commands in that specific directory/project, it brings me the commands that I used once. It's the same commands, over and over.
That happens even if in the terminal is printed
**Session contents restored from 5/17/2022 at 3:29:45 PM**
They are actually not
Can someone help?

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 ...

Matlab and simulink stateflow chart error

I have been trying to use "stateflow chart" block for hours. However, I keep getting this error:
The current directory is c:\program files\matlab13\bin, which is reserved for MATLAB files. Please change your current directory to a writable directory preferably outside of MATLAB installation area.
What I have done:
moved the model from bin to my E:\drive but nothing is going good.
But did you actually change directories. For example typing in the command window:
cd('E:\drive');
You could also change your current directory by changing the current folder from the second menu bar at the top of the Matlab window. If you do it either way, you should be no longer in the Matlab installation area and the first error message should not appear. If things are still not working out, you will have to share the new error message with us.

Where is startup.m supposed to be?

I've been chasing the answer to this question in the MATLAB documentation for a long time...
For example, at the bottom of
http://www.mathworks.com/help/matlab/matlab_env/changing-the-startup-folder.html
it says
Use the startup.m file to specify the startup folder...
...which is plainly absurd, since elsewhere the documentation says that startup.m is to be found in the so-called "startup folder". So therefore there's no way for this file to specify where this folder should be.
Etc., etc., etc. This sort of circularity pervades everything I've found in the docs on startup.m.
What I want to know is: can I or can't I customize the location of the "startup folder" in a way that is persistent, and if so, where is this persistent information stored?
The best method, I find, is this. Let's say you want MATLAB to start up in mystartupdir, and you've placed startup.m in that directory.
On Windows, make a shortcut icon to MATLAB, then right-click on it and select Properties. Edit the field Start In. Now, use this icon whenever you want to start MATLAB.
On other platforms, you can run MATLAB with the -sd flag to specify the startup directory:
matlab -sd mystartupdir
If you don't specify a startup directory, MATLAB will use the default specified by the userpath command. You can place your startup.m file there.
According to this page in the docs, you should create your own startup.m in the "startup directory" which, if you follow the link, leads to this page explaining the definition of "startup directory" in this context.
You can retrieve this "startup directory" with the userpath function which returns, on my system:
>> userpath
ans =
C:\Users\MYUSERNAME\Documents\MATLAB;
Personally, I just set the "Start In" in the shortcut to whatever I want - but obviously this won't work if you're not on Windows; if you're not on Windows or prefer not to rely on the shortcut you should create a startup.m with a call to cd in whatever directory userpath returns.
The docs also say you can modify the userpath function, if you so desire, or the matlabrc.m file in matlabroot/toolbox/local (but you can only do the latter if you're a MathWorks engineer or a system administrator, otherwise MathWorks will rain fiery hell down on you from above, or something...).
On Mac OS X, you may put your startup.m file in /matlabrootfolder/toolbox/local/. For example, this path might look like the following for Matlab 2012: /Applications/MATLAB_R2012a.app/toolbox/local/.
To prevent the file from being removed after upgrading Matlab, you may use a symlink to the file. If your startup file is stored at $HOME/myDir/startup.m, for example (in Bash):
cd /Applications/MATLAB_R2012a.app/toolbox/local/
ln -s ~/myDir/startup.m .
Reference: http://www.mathworks.com/help/matlab/matlab_env/startup-options.html
This is meant as a pointer for Lx users (as confused as I was at first...). I work on Debian based boxes, but the same should apply to the CentOS system lineup, etc.
Check that after install you do have the directory/ies: ~/.matlab/<yr_release(s)>
Note that you may have several releases there as is my case. matlab actually permits that.
Create ~/.matlab/startup.m Incidentally I also created my directory Workspace there. That's completely optional
In your Matlab window's Home tab find the menu iten/icon Set Path, click on it and add a "matlab search path" with the button Add folder top left. Add ~/.matlab as a new search path. Change should take effect immediately.
Restart Matlab to check that the content of ~/.matlab/startup.m is correctly taken into account at launch time.
I hate GUIs... I thought you might want to know ;-) HTH.
As read in http://fr.mathworks.com/help/matlab/matlab_env/matlab-startup-folder.html#buj_13n :
Changing the Startup Folder
Starting in R2014b, you can change the startup folder using the
General Preferences panel. On the Home tab, in the Environment
section, click Preferences. Select MATLAB > General. Choose an option
for the Initial working folder.
By default, the initial working folder is set to Location based on
MATLAB startup rules.
I wish it did not involve the graphical desktop interface, though. By looking closely in the file matlab.setting, which under Linux should lie in ~/.matlab/<your_release>/, you can find the lines
<key name="UserPath">
<string>
<value><![CDATA[<some_directory>]]></value>
</string>
</key>
where you can certainly specify manually the startup directory.
For me (I'm using Linux) it worked to put the "startup.m" to the home directory. Apparently, the home directory is by default on the matlab path. Strangely, it also worked when I put the "startup.m" into a newly created "matlab" (must be all lower-case) folder in the home directory. Let me know whether it also works on your system.

Running octave in Emacs

I am using run-octave in Emacs to trigger octave. Something is acting abnormally.
Every time I hit TAB to complete, there would be a tailing ^M; If I edit a .m file using edit a.m, it would start a new frame instead of a new buffer and the prompt is waiting for the closure of that frame so it would not respond to any input. How could I configure .emacs so that run-octave would behave normally?
Any comment is appreciated!
You seem to have two problems. I'm not sure about the trailing ^M, which seems to be caused by some sort of Windows/Unix CR/LF problem, but maybe I can help with the second problem.
The edit command uses the EDITOR environment variable to decide what to run. It seems that yours is either set to emacsclient or has defaulted to it. You haven't said whether you're on Unix or Windows, so I'm going to assume the former: you'll have to change this a bit for Windows.
To avoid the waiting thing, try running octave with a different EDITOR. For example, try out running
EDITOR='emacsclient -n' octave
When you type edit foo, it should bring up an Emacs buffer (if you want a new frame as well, use -c too) but not wait until you're done.
If this fixes things for you, you could change your ~/.bashrc to include the line
export EDITOR='emacsclient -n'