Hey Guys, I have a .mat file where I have written all the directories I will use. Lets say one of the directory is 'C:\Users\md\Desktop\A_I_001'. I want to make this directory changed in each iteration. so, the 'j' value will change in each time. How I can do that? Thanks in advance.
load tmp.mat; j='directory'; a = j; A =dir( fullfile(a, '*.png') );

回答 (1 件)

per isakson
per isakson 2014 年 3 月 27 日
編集済み: per isakson 2014 年 3 月 27 日

0 投票

Load the mat-file content to a variable
S = load('tmp.mat');
Inspect S to learn how the folder names are stored. I can only guess and assumes that in the mat-file each folder name is in one string variable. If so this loop should work
for folder_name = transpose( fieldnames( S ) )
A = dir( fullfile( S.(folder_name{:}), '*.png' );
...
...
end

4 件のコメント

Md
Md 2014 年 3 月 27 日
folder names are stored like this: 'C:\Users\md\Desktop\A_I_001' 'C:\Users\md\Desktop\A_J_001'
per isakson
per isakson 2014 年 3 月 27 日
編集済み: per isakson 2014 年 3 月 28 日
Yes, but those are the string values. There must be variable names of some kind! Run
S = load('tmp.mat')
and tell me what appears in the command window. Or run
clear
load('tmp.mat')
whos
Md
Md 2014 年 3 月 28 日
Hi, Thank you for your answer This is the output that I can see
Name Size Bytes Class Attributes
tmp 1x1 300 cell
per isakson
per isakson 2014 年 3 月 28 日
編集済み: per isakson 2014 年 3 月 28 日
tmp is a scalar, 1x1. What does
tmp{:}
show? And
S = load('tmp.mat')
?
Search a way to display the folder names in the command window and show the commands needed.

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

カテゴリ

ヘルプ センター および File Exchange で File Operations についてさらに検索

製品

タグ

タグが未入力です。

質問済み:

Md
2014 年 3 月 27 日

編集済み:

2014 年 3 月 28 日

Community Treasure Hunt

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

Start Hunting!

Translated by