comparison +grid/funcToMatrixTest.m @ 161:73bc43c7379e feature/grids

Added function for reshaping grid functions. Added size() method to structured grid.
author Jonatan Werpers <jonatan@werpers.com>
date Mon, 22 Feb 2016 13:20:55 +0100
parents
children
comparison
equal deleted inserted replaced
160:c700b26ad304 161:73bc43c7379e
1 function tests = funcToMatrixTest()
2 tests = functiontests(localfunctions);
3 end
4
5 function test1D(testCase)
6 inGf = [1 2 3 4 5]';
7 inM = 5;
8 out = [1 2 3 4 5]';
9 testCase.verifyEqual(grid.funcToMatrix(inGf, inM),out);
10 end
11
12 function test2D(testCase)
13 inGf = [11; 12; 21; 22];
14 inM = [2, 2];
15
16 out(1,1) = 11;
17 out(1,2) = 12;
18 out(2,1) = 21;
19 out(2,2) = 22;
20
21 testCase.verifyEqual(grid.funcToMatrix(inGf, inM),out);
22 end
23
24 function test3D(testCase)
25 inGf = [111; 112; 121; 122; 211; 212; 221; 222];
26 inM = [2, 2, 2];
27
28 out(1,1,1) = 111;
29 out(1,1,2) = 112;
30 out(1,2,1) = 121;
31 out(1,2,2) = 122;
32 out(2,1,1) = 211;
33 out(2,1,2) = 212;
34 out(2,2,1) = 221;
35 out(2,2,2) = 222;
36
37 testCase.verifyEqual(grid.funcToMatrix(inGf, inM),out);
38 end
39
40 function testNonSquare(testCase)
41 inGf = [
42 111;
43 112;
44 113;
45 114;
46 121;
47 122;
48 123;
49 124;
50 131;
51 132;
52 133;
53 134;
54 211;
55 212;
56 213;
57 214;
58 221;
59 222;
60 223;
61 224;
62 231;
63 232;
64 233;
65 234;
66 ];
67 inM = [2, 3, 4];
68
69 out(1,1,1) = 111;
70 out(1,1,2) = 112;
71 out(1,1,3) = 113;
72 out(1,1,4) = 114;
73 out(1,2,1) = 121;
74 out(1,2,2) = 122;
75 out(1,2,3) = 123;
76 out(1,2,4) = 124;
77 out(1,3,1) = 131;
78 out(1,3,2) = 132;
79 out(1,3,3) = 133;
80 out(1,3,4) = 134;
81 out(2,1,1) = 211;
82 out(2,1,2) = 212;
83 out(2,1,3) = 213;
84 out(2,1,4) = 214;
85 out(2,2,1) = 221;
86 out(2,2,2) = 222;
87 out(2,2,3) = 223;
88 out(2,2,4) = 224;
89 out(2,3,1) = 231;
90 out(2,3,2) = 232;
91 out(2,3,3) = 233;
92 out(2,3,4) = 234;
93
94 testCase.verifyEqual(grid.funcToMatrix(inGf, inM), out);
95 end