For loop error in App Designer
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
승곤 유
am 14 Mai 2022
Beantwortet: Image Analyst
am 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?
0 Kommentare
Akzeptierte Antwort
Image Analyst
am 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)));
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Downloads finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!