フィルターのクリア

How can I create an updating variable for a user input foler name?

1 回表示 (過去 30 日間)
Adam Takeshita
Adam Takeshita 2023 年 5 月 25 日
回答済み: Walter Roberson 2023 年 5 月 25 日
The fname variable will be changed manually in the first line, how can I have the 5th line automatically update the file name so I don't have to change it as well? Thank you in advance!
fname='Adam2.tif';
importfile(fname);
scan_loc=800
binsize=50
blah=Adam2(3:end,scan_loc-binsize/2:scan_loc+binsize/2)

回答 (1 件)

Walter Roberson
Walter Roberson 2023 年 5 月 25 日
scan_loc = 800;
binsize = 50;
filenums = [2, 7, 11:13]; %eg. you want Adam2, Adam7, Adam11, Adam12, Adam13
numfiles = length(filenums);
blahs = cell(numfiles, 1);
for K = 1 : numfiles
fname = "Adam" + filenums(K) + ".tif";
im = imread(fname);
blah = im(3:end, scan_loc-binsize/2:scan_loc+binsize/2, :);
blahs{K} = blah;
end
This will not give you variables named the same thing as your files; we recommend against dynamically creating variable names.

カテゴリ

Help Center および File ExchangeString Parsing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by