フィルターのクリア

For loop error in App Designer

3 ビュー (過去 30 日間)
승곤 유
승곤 유 2022 年 5 月 14 日
回答済み: Image Analyst 2022 年 5 月 14 日
1. image add button
global k;
global str2num;
file=uigetfile('*.*', 'select a single file at a time', 'download', 'MultiSelect','on');
k=length(file);
str2num();
2. filter button
global k;
for q = 1:k
c = char((file(q)));
imagec = imread(c);
imagec_=imagec(:,:,1);
mask=[-1 -1 -1; -1 9 -1;-1 -1 -1];
sharp_imagec_=imfilter(imagec_,mask);
imgchange(:,:,1)=sharp_imagec_;
imwrite(imgchange,strcat('gray',num2str(q),'.jpg')); %%각각 이미지를 저장
end
The above code is written in the app designer. The problem is that on execution, c = char((file(q))); This is where the double-type problem occurs. Script works fine, but App Designer doesn't.What can I do to fix it?

採用された回答

Image Analyst
Image Analyst 2022 年 5 月 14 日
file is not in scope in your second button. You can make it a global variable by attaching to the app structure so in the first "add" function, or by using the global keyword
app.file=uigetfile('*.*', 'select a single file at a time', 'download', 'MultiSelect','on');
k=length(app.file);
then in the second "filter" function use app.file
c = char((app.file(q)));

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by