Choosing specific columns and rows

4 ビュー (過去 30 日間)
Abdulhakim Alezzi
Abdulhakim Alezzi 2020 年 8 月 31 日
コメント済み: Abdulhakim Alezzi 2020 年 8 月 31 日
Hi everyone,
Is there anyone can help on the following matter :
I have a folder contains mualiple matfiles C1,C2,C3,C4.....C22. each mat files represent 30x30 matrix, named by (data).
1- I want to load all these files using for loop .
3- I want to pick up 8 rows and 8 columns from the 30x30 matrix from every matfile.
2- then i want to save them as y1, y2, y3,..... till y22.
I have tried this code to do the job, but the output was the same matrix for all the data
%%
N = 22;
D = 'path to the folder the files are saved';
for k = 1:N
F = fullfile(D,sprintf('C%d.mat',k));
S = load(F);
Y = data ([5:7 19 22 24:26],[5:7 19 22 24:26]);
F = fullfile(D,sprintf('Y%d.mat',k));
save(F,'Y')
end
  2 件のコメント
Stephen23
Stephen23 2020 年 8 月 31 日
Note that
D = 'path to the folder where the files are saved';
is unlikely to be the path to a valid folder. You should change that string so that it refers to a valid folder (just as the string states).
Abdulhakim Alezzi
Abdulhakim Alezzi 2020 年 8 月 31 日
Dear Stephen,
Actully I did not want to show my folder's name here . but in the actual code i am using the right folder name.

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

採用された回答

Stephen23
Stephen23 2020 年 8 月 31 日
編集済み: Stephen23 2020 年 8 月 31 日
Y = S.data(...);
^^ you need to access the field of structure S
  1 件のコメント
Abdulhakim Alezzi
Abdulhakim Alezzi 2020 年 8 月 31 日
Yes, This is helping.
Thank you very much.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStructures についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by