How to run a .m script for all folders in a directory?

조회 수: 6 (최근 30일)
Ivan Mich
Ivan Mich 2021년 4월 21일
댓글: Stephen23 2021년 4월 22일
Hello,
I have a question about a code. I have a .m script. This script requires 2 inputs in a folder in order to run. But I would like to run this .m script for all folders in a directory (path). The reason is that each input has different numbers so different results of each run of .m code will arise.
Could you please help me?
  댓글 수: 10
Rik
Rik 2021년 4월 22일
You should convert your matlab code to a function that accepts a path.
You should not use scripts for actual work. You should avoid cd, it is almost never required.
Attach your script so we can suggest edits. If it is just reading two files, that should not be hard.
Stephen23
Stephen23 2021년 4월 22일
"What should I do?"
Use functions.
Use absolute/relative filenames.
Avoid CD.
Avoid scripts for serious work (i.e. for anything versatile, expandable, repeatable, reliable, testable, ...)

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Search Path에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by