Octave - Multiple functions on 1 graph

By xngo on June 23, 2019

octave-3.2.4.exe:1> function y = a(x)
> y=3*x;
> endfunction
octave-3.2.4.exe:2> function y = b(x)
> y=5*x;
> endfunction
octave-3.2.4.exe:3> a(3)
ans =  9
octave-3.2.4.exe:4> b(3)
ans =  15
octave-3.2.4.exe:5> x=1:1:15;
octave-3.2.4.exe:6> plot( x, a(x), b(x) )
octave-3.2.4.exe:7>
octave-3.2.4.exe:7> title("Multiple functions on 1 graph")
octave-3.2.4.exe:8> xlabel("x")
octave-3.2.4.exe:9> ylabel("y")
octave-3.2.4.exe:10> grid

About the author

Xuan Ngo is the founder of OpenWritings.net. He currently lives in Montreal, Canada. He loves to write about programming and open source subjects.