For loop error in App Designer

1 visualizzazione (ultimi 30 giorni)
승곤 유
승곤 유 il 14 Mag 2022
Risposto: Image Analyst il 14 Mag 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?

Risposta accettata

Image Analyst
Image Analyst il 14 Mag 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)));

Più risposte (0)

Categorie

Scopri di più su Downloads in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by