문제

In the bash script, it is possible to do following:

    cat > my.txt << EOF
         bla-bla-bla
         bla-bla-bla
         bla-bla-bla
    EOF

Is there any way I could execute this command inside a matlab m-file? I am thinking about system, but it seems it accept only simple one-string system commands.

도움이 되었습니까?

해결책

You can create a system command that contains linebreaks with sprintf:

system_command = sprintf('cat > my.txt << EOF\n');
system_command = sprintf('%s\nbla-bla-bla', system_command);
system_command = sprintf('%s\nbliblablub', system_command);
system_command = sprintf('%s\nEOF', system_command);
system(system_command);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top