MUSC 208. Computer Music and Sound. Winter 2014

Unit 3 Lecture - Octave Functions

Fahrenheit to Celsius

f2c

1. Open Octave.

2. Find Octave's working directory pathname.

3. Open a new blank document in your text editor.

4. Save the file as "f2c.m" in Octave's working directory.

5. Create a skeleton function called f2c

[ret] = f2c( c )
... code goes here
endfunction

f = 5 * ( c - 32 ) / 9;
ret = f;

Test it

f2c test

Celsius to Fahrenheit

c2f

1. Open Octave.

2. Find Octave's working directory pathname.

3. Open a new blank document in your text editor.

4. Save the file as "c2f.m" in Octave's working directory.

5. Create a skeleton function called f2c

[ret] = f2c( f )
... code goes here
endfunction

c = ( 9 * f / 5 ) + 32
ret =c;

Test it

c2f test

[Syllabus]

Revised John Ellinger, Winter 2014