How do i loop over multiple lines of codes?
Show older comments
Is this correct:
Gil=dir('C:/users/document/reut/*.jpg');
for u=1:150
Name=strcat('C:/users/document/reut/',Gil(u).names);
F=imread(Name)
[ca,ch,cv,cd]=dwt2(F,'haar');
Mi= mean(min(ca));
Mig= mean(min(cv));
xlswrite('Mi.xls', Mi)
xlswrite('Mig.xls',Mig)
end
This code intends to decompose several images from the path and Use the results to get Mi and Mig while it also extract these values of Mi and Mig for each of the images in the loop and save them in a .xls file. Mi and Mig taking two columns and their values for each image in rows without overwriting or interference.
But these codes are not working. Please help me. I am new to MATLAB
1 Comment
dpb
on 7 Mar 2020
So, what isn't working?
Couple minor stylistic points...
subdir='C:/users/document/reut'; % define as variable instead of duplicating text in line
Gil=dir(fullfile(subdir,'*.jpg')(); % fullfile() to build name from pieces
for u=1:numel(Gil) % iterate over the returned size instead of constant
Name=fullfile(subdir,Gil(u).name); % fullfile but field is .name (NOT plural .names)
...
Your code above will also overwrite the two .xls files each pass through when it does run leaving only the last pass.
What is expected output?
Answers (0)
Categories
Find more on Wavelet Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!