Good Morning, I'd like to sort folders from a folder, let's say:
I have the folder "A" which contains folders:
1
2
3
4
5...
100
if I use
d = uigetdir('C:\A\number') %where number is the name of the folder,it works.
What about taking 'number' as a variable inside the "uigetdir"? Thanks, jahnludvik

 採用された回答

Adam
Adam 2015 年 2 月 20 日
編集済み: Adam 2015 年 2 月 20 日

0 投票

n = 10;
d = uigetdir( [ 'C:' filesep 'A' filesep num2str(n) ] )
should work. There are other ways to compose a filename from parts if you prefer, using the fullfile function, but it is equivalent so it's up to you.
fullfile( 'C:', 'A', num2str(n) );
would be the fullfile alternative.

5 件のコメント

ludvikjahn
ludvikjahn 2015 年 2 月 20 日
sorry, but it just open a directory where I have to choose it manually... is there a way to automatically choose my folder?
Adam
Adam 2015 年 2 月 20 日
What do you mean by automatically open it?
When I tried that on my command line it took me to the folder in question in the file browser from where I could make whatever selection I want.
If you don't want any manual part to the process then why are you using uigetdir? You have the folder name as the argument to uigetdir so you can just use that folder name in code instead if that is what you want.
ludvikjahn
ludvikjahn 2015 年 2 月 20 日
編集済み: ludvikjahn 2015 年 2 月 20 日
but in the case I have a folder which name is not a number but a string, I thought I could use your script without num2str. In this caseit just sends me to the folder:
C:\A\n.
I hoped that uigetdir could help, but it just opens another different directory as the one open in my workspace.
ludvikjahn
ludvikjahn 2015 年 2 月 20 日
It opens the folder which is open in my workspace
ludvikjahn
ludvikjahn 2015 年 2 月 20 日
I found the way, thanks

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeSearch Path についてさらに検索

質問済み:

2015 年 2 月 20 日

コメント済み:

2015 年 2 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by