0

I have a general path

C:\Users\Dr Syed Abdul Rahman\Desktop\innovation final.

However I don't know how can I change my MATLAB path to

C:\Users\Dr Syed Abdul Rahman\Desktop\innovation final\Fingerprint 

or

C:\Users\Dr Syed Abdul Rahman\Desktop\innovation final\Image.

I know the cd command in MATLAB, but suppose that if this file is portable to other PC? Could anyone guide me how can I change my directory in somehow that does not need the full address? Because I have classified my image, folders, files and code...

2 Answers 2

3

I'm fairly confident you can use relative paths with cd:

cd Fingerprint

And change back with

cd ..

Although I must ask - are you sure you want to be changing directories? Or should you instead be using relative paths when opening files? (eg. Image/foo.jpg)

Sign up to request clarification or add additional context in comments.

Comments

0

Have a look at uigetfile -- it opens a normal dialog box that lets the user select a file in any location.

Alternatively, if you are running a script and you know that the image(s) is (are) always located in the same spot relative to that script, you can use fileparts in combination with mfilename('fullpath') to get the full path to the running script, and then append the rest via string concatenation. Something like this:

scriptPath    = fileparts(mfilename('fullpath'));
imageLocation = [scriptPath filesep 'Image' filesep];

img = imread([imageLocation 'your_image.jpg']);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.