필터 지우기
필터 지우기

Saving a matrix to a series of different created folders

조회 수: 6 (최근 30일)
Ursula Trigos-Raczkowski
Ursula Trigos-Raczkowski 2023년 4월 14일
댓글: Voss 2023년 4월 14일
I am trying to make several different folders named C1, C2, C3, etc. and save a resulting matrix in each of them, so
C1 would have C1_Mat.csv in it, C2 would have C2_Mat.csv in it, etc.
I am going to simplify my code below since I already have the BoolMat stuff figured out giving a different matrix each time, I'm just having trouble with the actual saving of the csv file to the folder.
thank you.
for part= 1:3
BoolMat1=[1,1,1];
mkdir(sprintf('C%g',part))
fullfile(sprintf('C%g_Mat.csv',part),BoolMat1)
end

채택된 답변

Voss
Voss 2023년 4월 14일
for part = 1:3
BoolMat1 = [1,1,1];
dir_name = sprintf('C%g',part);
mkdir(dir_name)
file_name = fullfile(dir_name,sprintf('C%g_Mat.csv',part));
writematrix(BoolMat1,file_name);
end
  댓글 수: 2
Ursula Trigos-Raczkowski
Ursula Trigos-Raczkowski 2023년 4월 14일
thank you so much! you saved me so much time!
Voss
Voss 2023년 4월 14일
You're welcome!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by