How do i loop over multiple lines of codes?

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 件のコメント

dpb
dpb 2020 年 3 月 7 日
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?

サインインしてコメントする。

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeWavelet Toolbox についてさらに検索

製品

リリース

R2015b

質問済み:

2020 年 3 月 7 日

コメント済み:

dpb
2020 年 3 月 7 日

Community Treasure Hunt

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

Start Hunting!

Translated by