0

I have a script like:

#!/opt/bin/octave -qf
xin = dlmread(argv(){1},",");
tim = dlmread("Time");
fileout = [argv(){1} "-" "avg"];
## calcs to create xtemp and time matrices
dlmwrite("Time-avg",time);
dlmwrite(fileout,xtemp,",");
## ?? unix("paste -d',' Time-avg fileout > DATCOARSE");

This all works fine until the last line. I create fileout inside the script to correlate with the input datafile, and fileout prints out fine.

Is there some kind of dereferencing operator in octave to use "fileout" in the unix or system command?

1 Answer 1

1

You can use sprintf to create the command string:

cmd_str = sprintf ("paste -d',' Time-avg %s > DATCOARSE", fileout);
unix (cmd_str)

But you don't have to use "paste" at all. You can just concatenate the matrices in octave

dlmwrite ("DATCOARSE", [time, xtemp], ",");
Sign up to request clarification or add additional context in comments.

2 Comments

Earlier I found this worked: cmd = sprintf ("%s%s%s%s%s", "paste -d", "','", " Time-avg ", fileout, " > DATACOARSE"); system(cmd); which is what you have suggested as well. Yes, [...] does work as well, and is probably faster. Thanks.
@LesterIngber: Any reason you don't mark this as answered?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.