MATLAB path doesn't match pathdef - matlab

I am running MATLAB 2013b on a CentOS machine. Right now I have startup.m set to cd me into another directory, lets call it shared, where I keep all of my code. I also have pathdef.m set to add shared and some of its subdirectories to the MATLAB path.
The problem is that once MATLAB is open and I check the path settings, ~/matlab has also been added to the top of the path list, ahead of shared. The home folder is where I keep some old versions of code, so it causes the wrong version to be run sometimes. I've double checked my pathdef and startup files, and the ~/matlab directory is definitely not listed. What could be causing MATLAB to automatically add this directory to the path, and how can I fix it?

Related

Changing current working directory (cwd) to current file directory in VSCode

So I'm trying to change the directory the integrated terminal runs my Python scripts in from the root workspace (the default, I guess) to the running file directory. I want to do this as I'm more used to work with paths relative to running file than to root dir. Also sometimes I use quite large directory trees and even paths to near directory files get quite long by starting them from root dir. This would also allow me to use Path Intellisense extension as it seems to base suggestions on the current file dir.
I heard about changing the lauch.json file but I'm looking for a definitive solution that avoids having to change this in all projects.
I have already tried to change settings.json cwd option to "terminal.integrated.cwd": "${fileDirname}" but it doesn´t seem to take any effect, even after reloading.
I'm not sure what other infos are relevant here, but nevertheless i'm running vscode on windows 11 version 21H2. Any other info feel free to ask.
Thank you all in advance

Matlab path not saving with GUI (Ubuntu 12.04)

I am trying to edit my MATLAB path. I have permission, it does not give me an error when I try to edit via the GUI, but when I close and reopen matlab, the changes are gone.
I have edited ~/matlab/startup.m to include the paths I need the most, and this works, but why can't I edit the path via the GUI?
I assume it is saving my path (because there is no permission warning/error), but it may be that something is destroying those changes, or reverting upon each startup, I guess I'm just not entirely sure where to look.
EDIT: I should mention that I did not set this machine up, and it's a UNIX box that may have other configuration scripts that are messing with the path. (I checked bashrc but there's nothing there that would interfere)
Found a script that the previous admin put into the machine's global profile that automatically sets the path to include various toolboxes.

Fatal Error: "MATLAB_PREFDIR must be an absolute path. Cannot set preferences directory to the relative path.." occurs when spmd is used

I am running a program on Matlab and I use spmd to parallelize my code.
The same code runs on 2 different PCs. One of them runs perfectly well, but the other doesn't and the Fatal Error occurs.
If I try to run a non-parallelized program, there are no errors. I don't know if there is a problem with this specific command or if I did something wrong myself.
Could it be related to the directories in which I have saved my code files?
If so then why does the non-parallelized program run?
I'm not sure if you still have this problem, but anyway...
The problem is with the path to preferences folder. So, you need to change it.
Mostly such error occurs if you don't have write access to this folder or its located in hidden folder.
To open the current path of the prefdir type winopen(prefdir) in matlab Command window. Then copy all files from this folder into new one (for instance C:\MATLABPreferences).
Now you need to change a path of the prefdif using .bat file with the following text:
fullfile (matlabroot, 'bin', 'matlab')
set MATLAB_PREFDIR=<New preference folder location>
"<MATLAB executable location>"
Example:
fullfile (matlabroot, 'bin', 'matlab')
set MATLAB_PREFDIR=C:\MATLABPreferences
"C:\Program Files\MATLAB\R2013b\bin\matlab.exe"
Run it and enjoy parallel computing with matlab.
More detailed explanation you can find here.
I've had problems with this, and so far the internet was not really useful. After hours of Googling, this turned out to be useful. You just need to add a new variable to your environmental variables (in case you are using Windows) named MATLAB_PREFDIR with the location of the preferred directory.
For me, it is C:\Users\Balázs\AppData\Roaming\MathWorks\MATLAB\R2014a, but you can get if you type prefdir into matlab's command line.

eclipse window not opened when i am trying to click eclipse.exe

When i am trying to open eclipse exe file , window is not opened , why this is happened , previously it is working fine but today it is not opened any changes i need to do?it will help full if any one gave quick fix .
thanks
Ramana
(The OP ramana solved it by uninstalling and re-installing Java, but below is another potential cause)
Check if your PATH hasn't changed somehow: see Java Tips: “Adventure” in resolving the Java error “Error occurred during initialization of VM”
Running Java.exe produce error in other directories (since the SDK’s bin is added to path.)
However running in it’s bin directory, it runs fine.
In the case of the ips mentioned before, the issue was:
The good news is that it is nothing supernatural or magical image but the bad news is that the Windows directory is the “protagonist” image.
From file search, it can be concluded that somehow certain mischievous program is copying some crucial java files into Windows directory which are stored in path, and so unless the java’s bin is the foremost in the path, one will bound to get the error.
The error occurs because java.exe or other Java executable expect some support files and directories to be found but obviously could not find it in Windows directory.
Running the java.exe in its bin directory will not produce error because Windows will use the current directory to which the file is run first before searching for it in the path.
That might not be the case for you, but that could still be related to a PATH issue.

How to use relative paths for projects added to an Eclipse workspace?

I am working on some Eclipse projects that are stored on a USB key. I have added them to a workspace whose root folder is also on the USB key, but the projects are not located directly into this directory. As a result their absolute paths are written in the .projects folder of the workspace.
This raises problems when I use the key on several computers, because the drive letter assigned to the USB key is not always the same (and I do not want to assign a specific letter to it on all computers). Eclipse cannot open my projects when the drive letter differs from that of the USB key at the time I added the project to the workspace.
Is there a solution to this problem ? Specifically, is there a way to make Eclipse add projects to a workspace by using their relative path from the workspace folder ?
Its really not that hard. You just have to assign a new variable that points to WORKSPACE/..;. For example, you can use the Forge Minecraft modder pack - it has a workspace that is immediately ready no matter what machine downloads it, where you place it or even if you move it.
Download this:
http://files.minecraftforge.net/minecraftforge/minecraftforge-src-1.6.2-9.10.0.789.zip
And then unzip it and run install.bat/cmd. Then check the contents of forge/mcp/eclipse/Minecraft/{.project,.workspace} to see some examples.
I've got my workspace working on github like this.
In my experience it will break at some time if you try to "hack" the metadata of eclipse.
Consider the substcommand in windows (As you mention drive letter I assume windows)
create a bat file containing
subst N: .
Running this will mount the current dir as N: So You can place this on the usb drive, and run that prior to running eclipse, then You will always find the same content on drive N:
To remove the mount do
subst /D N:
You might consider making a bat file that mount N:, start eclipse and after eclipse exit unmount N: something like
startMyProject.bat:
subst N: .
N:/eclipse <yadayada options>
subst /D N:
The short answer is that you cannot do it without hacking your workspace metadata (under [workspace.dir]/.metadata). Eclipse workspaces aren't designed to be portable and even though you are not physically moving your workspace, you are in effect moving it by changing drive letters.
I'd recommend trying to find a way to have your projects under workspace.dir. Not guaranteed that you will not have problems that way, but may improve your odds. Depending on what features of Eclipse you use, you may very well end up with other types of absolute paths in your workspace metadata.
This question is kinda old, but there's an entirely different approach: You can create a Junction from the Folder where Eclipse expects the Project, for example E:\foo\workspace\myproject and link it to where the project lays, for example E:\bar\myproject.
A Junction essentially means that you can access the same folder through 2 different paths, thus you don't need to worry with the weird relative path limitations of Eclipse. To create it easily and fast, I recommend you to get Link Shell Extension
I haven't tried this myself, but this might work. Try:
Add your source folder as linked resource & remove previous definition:
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse.platform.doc.user/tasks/tasks-45.htm
Close eclipse and find your project folder in your workspace (ex: C:\Documents and Settings\username\workspace\yourproject\) Replace absolute paths in files .project & .classpath with relative paths.