For a bit of context, I am trying to create a series of 20000 scenarios given an input parameter of my choosing, and label those newly created files with a file name and the numeral of the paramter I am changing. Below is a portion of the script
function startup
cd ~/Desktop/program/scenario/
%
for X= 100:100:500
mkdir Scenario-NumberX %X is the changing variable which a file name will be made
cd ..
copyfile(['scenario','/*.prm'],'~/Desktop/program/scenario/Scenario-NumberX'
%under 'scenario' should be a number of files of my choosing with parameter files
% each iteration through the loop should be creating a file and placing it in the desired location.
end
Any and all help is appreciated!

댓글 수: 2

Star Strider
Star Strider 2019년 1월 18일
The mkdir function creates a new directory (folder) not a new file.
Are you sure you want to do that?
Charles Cummings
Charles Cummings 2019년 1월 18일
Yes apologies, misspoke. I have prm files in another folder I am moving into it every iteration.

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

 채택된 답변

Sean de Wolski
Sean de Wolski 2019년 1월 18일

0 개 추천

for ii = 1:10
mkdir("Scenario" + x)
end

댓글 수: 4

Charles Cummings
Charles Cummings 2019년 1월 18일
mkdir only accepts character arrays. I have tried using mkdir in command syntax and as a function as you just did, but it hasnt worked.
Charles Cummings
Charles Cummings 2019년 1월 18일
편집: Charles Cummings 2019년 1월 18일
Also, I havent been able to use that scenario directory created inside of copyfile ie as a loaded variable
This works in newer releases. In older releases
mkdir(['Scenario' num2str(ii)])
Charles Cummings
Charles Cummings 2019년 1월 18일
Perfect thank you. The other issue was taking that name I created with mkdir and adding it to the end of copyfile. Tried this
copyfile(['scenario','/*.prm'],['~/Desktop/program/scenario/Scenario-NumberX' convertStringsToChars('Scenario100')])
Should I create a new thread?

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 File Operations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by