Skip to content

Commit e5c6c46

Browse files
author
Marek Rudnicki
committed
example: eval m-file
1 parent 8cc2fa5 commit e5c6c46

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

examples/eval_m_file.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# -*- coding: utf-8 -*-
2+
3+
"""Evaluate m-file and collect the results.
4+
5+
"""
6+
from __future__ import division, print_function, absolute_import
7+
from __future__ import unicode_literals
8+
9+
__author__ = "Marek Rudnicki"
10+
__copyright__ = "Copyright 2014, Marek Rudnicki"
11+
__license__ = "GPLv3+"
12+
13+
14+
import matlab_wrapper
15+
16+
17+
def main():
18+
matlab = matlab_wrapper.MatlabSession()
19+
20+
matlab.put('x', 2.)
21+
matlab.eval('my_script')
22+
y = matlab.get('y')
23+
24+
print("And the winner is:", y)
25+
26+
27+
if __name__ == "__main__":
28+
main()

examples/my_script.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
% Basic MATLAB script
3+
4+
y = x * 2;

0 commit comments

Comments
 (0)