How to write a script to edit another script ?
이전 댓글 표시
I have a script lets call it scriptA, that contains parameter names and assigned values. I am trying to write a script (scriptB) that will edit scriptA by changing both the parameter names and the values. I will be reading in a excel spreadsheet that contains the names and values that I will be assigning. How should I go about this?
채택된 답변
추가 답변 (1개)
Steven Lord
2015년 8월 14일
1 개 추천
Why not make scriptB into a function that accepts input arguments and/or reads in a data file in a known format and pass the varying parameters into that function?
댓글 수: 2
Rodriguez Pham
2015년 8월 14일
Steven Lord
2015년 8월 14일
Rather than writing a script:
PLACEHOLDER_NAME = 2*PLACEHOLDER_VALUE
whose PLACEHOLDER_* entries you replace with contents from another file, instead write a function:
function y = timesTwo(x)
y = 2*x;
You can then call timesTwo wherever you would invoke the script:
z = timesTwo(17);
where 17 is data you read from a file or something.
카테고리
도움말 센터 및 File Exchange에서 Common Operations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!