Skip to content

Commit

Permalink
init, octpy not working for classes yet?
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed Jan 16, 2018
1 parent c3030da commit 78cd36e
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
28 changes: 28 additions & 0 deletions oct2py_class.m
@@ -0,0 +1,28 @@
% https://www.mathworks.com/help/matlab/matlab_oop/create-a-simple-class.html
% testing classes in Octave >= 4.0

classdef oct2py_class
properties
Value
end
methods
function obj = oct2py_class(val)
if nargin == 1
if isnumeric(val)
obj.Value = val;
else
error('Value must be numeric')
end
end
end
function r = roundOff(obj)
r = round([obj.Value],2);
end
function r = multiplyBy(obj,n)
r = [obj.Value] * n;
end
function r = plus(o1,o2)
r = o1.Value + o2.Value;
end
end
end
15 changes: 15 additions & 0 deletions oct2py_class.py
@@ -0,0 +1,15 @@
#!/usr/bin/env python
from oct2py import Oct2Py

val = 3.5 # arbitrary

with Oct2Py() as oc:
a = oc.oct2py_class()

a.Value = val

print(a.Value)
print(a.roundOff)



0 comments on commit 78cd36e

Please sign in to comment.