For loop error in App Designer

1 vue (au cours des 30 derniers jours)
승곤 유
승곤 유 le 14 Mai 2022
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?

Réponse acceptée

Image Analyst
Image Analyst le 14 Mai 2022
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)));

Plus de réponses (0)

Catégories

En savoir plus sur Downloads dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by