Let's say I have a matlab file that calculates some values, giving:
alpha = 7
beta = 9
Now, I want to pass these values to a Bash script for use.
What is the syntax for doing this?

 채택된 답변

Walter Roberson
Walter Roberson 2019년 3월 17일

0 개 추천

Example:
cmd = sprintf('alpha=%d beta=%d ls | head -$beta | tail -$alpha', alpha, beta);
system(cmd)

댓글 수: 3

g
g 2019년 3월 17일
Thanks! What do head and tail do? What if I desire to pass a third variable?
cmd = sprintf('first_variable=%d second_variable=%d third_variable=%d command to execute goes here and refers to $first_variable and $second_variable and $third_variable', first_var, second_var, third_var)
cameron morrison
cameron morrison 2020년 3월 5일
i can't seem to get this to work at all. Is there anything I have to write on the Linux command line?

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

추가 답변 (0개)

카테고리

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

태그

질문:

g
g
2019년 3월 17일

댓글:

2020년 3월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by