Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have written some code for Matlab/Octave. Basically, they have the same syntax and everything, but, for example, they have different functions for optimization (linprog/glpk,quadprog/qp).

I want to run the same code in both Matlab and Octave and this code suffers from needing different functions in each environment. Until now, I have a variable that tells the programm whether it is running on Matlab or on Octave, but I always have to set this variable manually.

Is there a way that a program can recognise in which environment it runs? So, I want a statement to set the variable x=1, if it is running on Octave and x=0 if it is running on Matlab.

share|improve this question

migrated from math.stackexchange.com Dec 1 '11 at 13:34

This question came from our site for people studying math at any level and professionals in related fields.

    
I'm not sure this is a question that is appropriate here... –  J. M. Dec 1 '11 at 12:56
    
I am sure. It's not. –  Manos Dec 1 '11 at 13:00
    
I'm fairly sure that this question is in the wrong forum. My first guess would be that the answer depends on the OS, but I did most of my programming under DOS, so probably shouldn't comment. Migrate to SO? I will flag a moderator. –  Jyrki Lahtonen Dec 1 '11 at 13:13
    
Ideally one should ask this at the MatLab or GNU Octave mailing lists/fora. But this is clearly off-topic. I'll migrate to SuperUser. As Jyrki pointed out, it may require making system calls and what not. –  Willie Wong Dec 1 '11 at 13:33
    
Sorry I didn't know where to post it. Thanks for your help. –  pirad Dec 2 '11 at 6:21

1 Answer 1

up vote 2 down vote accepted

You could check whether Octave’s built-in variable OCTAVE_VERSION is set.

share|improve this answer
    
Thanks this idea was what I needed. –  pirad Dec 2 '11 at 6:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.