How to add folder automatically

6 ビュー (過去 30 日間)
Pat
Pat 2014 年 5 月 8 日
コメント済み: Leah 2014 年 5 月 8 日
I have a folder named project,inside this project folder i have many .m files and 3 folders(images,imaeges1,code) inside the images and images 1 folder i have many images,this project folder is in D drive
In a gui for displaying images in axes i usedthe code imread('D:\projects\images\2.jpg')
It working fine and i get the answer
Now i want to run this code in another systen where D drive is not tere,so manually i have to change the path, I have createdmany axes and i have to do it manually ,if i run code in diferent machines
Is thera any wat to do this automatically,i dont want to change the path if i run on each machine

採用された回答

Michael Haderlein
Michael Haderlein 2014 年 5 月 8 日
Why don't you just use a relative path? imread('images\2.jpg')
Best regards, Michael
  1 件のコメント
Leah
Leah 2014 年 5 月 8 日
I copied this from gui code I had for a callback. my callbacks are in a different folder an I didn't want to write to the folder containing my callbacks, so I didn't want the relative path.

サインインしてコメントする。

その他の回答 (2 件)

nl2605
nl2605 2014 年 5 月 8 日
uigetfile and fullfile is what you need.
  1 件のコメント
Pat
Pat 2014 年 5 月 8 日
no no i want to add folders to my project folder when run on different machines

サインインしてコメントする。


Leah
Leah 2014 年 5 月 8 日
This will create one in the working directory
foldername='newfoldername'
mkdir([pwd '\' foldername])

カテゴリ

Help Center および File ExchangeConvert Image Type についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by