How can I execute an external command from octave?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How can I execute an external command from octave?

che6yoh
Dear Sirs,

I am trying to convert my MATLAB files to be used in OCTAVE.

I made some commands which are supported in MATLAB and are not
in OCTAVE, filter etc.

Because OCTAVE cannot deal with Vectors of strings,
I used length of string as a index of the vector
length=500*number_of_elements+string_length.
But abs can't be used to get ASCII codes or setstr isn't
supported.

I misunderstood I could use "!" as shell escape.
And I made a C program named setstr and setstr.m as follows.

Is there anyway in which external commands can be executed from
octave?

I will appreciate your help very much.

Yours faithfully,

Yoshihiro Hashimoto
Dept. of Systems Eng., Nagoya Inst. of Tech. Japan
[hidden email]
I am in Leeds Univ. U.K now.  [hidden email]
The mail sent to Japanese address is automatically sent to
English address.
-----------------------------------------------------------
function y = setstr(x)
  f='setstrda';
  d=getenv("OCT");
  for i=1:100
    file=strcmb(d,f,num2str(i));
    if exist(file)==0,break;endif
  endfor
  z=x;
  save file z;
  command=sprintf("!setstr %s",file);
  eval(command);
  load file;
  y=z;
endfunction


Reply | Threaded
Open this post in threaded view
|

Re: How can I execute an external command from octave?

John Eaton-3
: I misunderstood I could use "!" as shell escape.

In Octave, `!' is used as another operator for logical negation.

: Is there anyway in which external commands can be executed from
: octave?

You can use the function `shell_cmd'.  The first argument is a string
containing the command to execute.  If you specify a second argument,
shell_cmd will return the output of the command in a string.

--
John W. Eaton      | The exam demonstrates a comminuted, slightly overlapping
[hidden email] | angulated fracture of the midfifth metatarsal.