On 04.08.2010 19:35, Eric Blossom wrote:
>> Why making a difference? Most code is compatible between Octave and Matlab.
>> Even Matlab C++ MEX functions compile very well in Octave.
>> The Octave scripts in gnuradio are not working in Matlab, because they use
>> Octave-specials (comments as ## instead of %%, endfor instead of end).
>> I'm used to code in a style that both Matlab and Octave understand.
> Please send a patch to fix the comments.

I didn't change those manually, instead I wrote a bash script for this task,
see attachment. It can patch all octave-scripts at once.
But this is not perfect. In octave both ! and ~ allowed for negating,
in matlab just ~. This is not handled. I made no tests, since I
use my own signal processing and analysis toolbox.
There is a better converter:
http://octave.sourceforge.net/oct2mat/
but this also replaces functions calls, which may result in
octave-incompatible code.

It always has to be tested for compatibility. There are some
differences between Octave and Matlab, concerning
available commands and so called 'object oriented' functions.
Sometimes it works without modifications, sometimes not.
At least for my code, I try do avoid proprietary specials.

It's an ideological question (promoting Octave over Matlab),
whether we want the Octave-only style  (which looks better indeed),
or a Matlab-compatible style.I don't want to judge about this,
since I didn't contribute to the gnuradio code (yet).

Moeller


#!/bin/bash
# usage:
#   octavescript2matlabscript *.m
#
# convert all Octave Scripts into MATLAB Scripts (translating # comments, 
endfunction)

if [ $# -eq 0 ]; then
  echo "usage: octavescript2matlabscript *.m"
  exit
fi

for name in "$@"; do 

  # only process scripts with relevant octave-only entries
  grep -q '\(^[ \t]*#.*\)\|endfunction\|endfor\|endif' "$name"
  if [ "${?}" -eq "0" ] ; then

    echo $name
        sed -i 's/^\([ \t]*\)##\(.*\)/\1%%\2/g;s/^\([ 
\t]*\)#\(.*\)/\1%\2/g;s/endfunction/end/g;s/endfor/end/g;s/endif/end/g' $name
        
  fi

done
_______________________________________________
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
http://lists.gnu.org/mailman/listinfo/discuss-gnuradio

Reply via email to