1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
| | #+Title: A collection of examples for ob-matlab tests
#+OPTIONS: ^:nil
* Test MATLAB results output
:PROPERTIES:
:ID: 99332277-5e0e-4834-a3ad-ebcaddb855ab
:END:
#+begin_src matlab :results output
disp('The results are:')
a = [1, 2; 3, 4]
b = a * 2
#+end_src
#+RESULTS:
#+begin_example
The results are:
a =
1 2
3 4
b =
2 4
6 8
#+end_example
Following validates whitespace is preserved
#+begin_src matlab :results output
disp(' +---+')
disp(' |one|')
disp(' +---+')
disp(newline)
disp([' ', num2str(1)]);
disp(newline)
disp(' +---+')
disp(' |two|')
disp(' +---+')
disp(newline)
disp([' ', num2str(2)]);
disp(newline)
#+end_src
* Test reuse of MATLAB buffer with results output
:PROPERTIES:
:ID: a68db9ff-efdf-42b9-85fc-174015cd1f77
:END:
#+begin_src matlab :results output
a = 123
#+end_src
#+RESULTS:
: a =
:
: 123
#+begin_src matlab :exports both :results output
b = a + 1000
#+end_src
#+RESULTS:
: b =
:
: 1123
Following should give: Unrecognized function or variable 'b'.
#+begin_src matlab :results output
clear
c = b * 2
#+end_src
#+RESULTS:
: Unrecognized function or variable 'b'.
* Test results verbatim
:PROPERTIES:
:ID: 278047b6-4b87-4852-9050-e3e99fcaabb8
:END:
#+begin_src matlab :results verbatim
a = 2 + 3;
ans = magic(a);
#+end_src
* Test results output latex
:PROPERTIES:
:ID: 7a8190be-d674-4944-864e-6fdaa7362585
:END:
#+begin_src matlab :results output latex
m = [4*pi, 3*pi; 2*pi, pi];
result = latex(sym(m));
disp(result)
#+end_src
* Test results file graphics
:PROPERTIES:
:ID: 5bee8841-a898-4135-b44b-f1bd5465ceed
:END:
#+begin_src matlab :results file graphics :file NAME.png
t = [0 : 0.1 : 2*pi];
y = sin(t);
plot(t, y);
set(gcf, 'PaperUnits', 'inches', 'PaperPosition', [0 0 4 3]) % Set the size to 4" x 3"
#+end_src
# LocalWords: ebcaddb efdf fc fcaabb fdaa ceed sinewave
|