help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Make Octave behave more like Matlab


From: John W. Eaton
Subject: Make Octave behave more like Matlab
Date: Fri, 16 Feb 2007 15:22:29 -0500

On 16-Feb-2007, Matthias Brennwald wrote:

| I use Octave to develop code that is intended to run on both Octave  
| and Matlab. I found that Octave sometimes does things that Matlab  
| won't. For example:
| 
| 
| 1. Strings can be defined with single or double quotes in Octave,  
| while Matlab only accepts single quotes. For instance, this will work  
| in Octave, but not in Matlab:
| 
| myString = "Hello";

Have you reported this bug to the MathWorks?

| 2. switch / case statements: Matlab requires a comma after the case  
| statements, Octave doesn't. For instance, the following will work in  
| Octave, but not in Matlab (which requires commas after 'red' and  
| otherwse):
| 
| color = 'green';
| switch color
|       case 'red'
|               disp('It is red.');
|       otherwise
|               disp('It is not red.');
| end
| 
| 
| My problem with this is that when I test my code with Octave, I don't  
| get any errors or warnings, but then I get complaints from Matlab  
| users because I wrote something that Matlab does not like. Is there a  
| way to make Octave act more like Matlab?

Octave 2.9.9:

  octave2.9:1> warning error Octave:matlab-incompatible
  octave2.9:2> StudlyCapsConsideredHardToRead = "Hello";
  error: potential Matlab compatibility problem: " used as string delimiter

and

  octave2.9:2> color = 'green';
  octave2.9:3> switch color
  >   case 'red'
  >     disp('It is red.');
  >   otherwise
  >     disp('It is not red.');
  > end
  It is not red.

so I guess this one isn't flagged.

I don't really care whether there is a warning here or not, but I
would consider a patch.

jwe


reply via email to

[Prev in Thread] Current Thread [Next in Thread]