comparison reshapeToPlotMatrixTest.m @ 820:501750fbbfdb

Merge with feature/grids
author Jonatan Werpers <jonatan@werpers.com>
date Fri, 07 Sep 2018 14:40:58 +0200
parents 51aaf67a7df5
children
comparison
equal deleted inserted replaced
819:fdf0ef9150f4 820:501750fbbfdb
1 function tests = reshapeToPlotMatrixTest()
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(reshapeToPlotMatrix(inGf, inM),out);
10 end
11
12 function test2D(testCase)
13 x = 1:2;
14 y = 1:3;
15
16 f = @(x,y) x + y*10;
17
18 xx = [1; 1; 1; 2; 2; 2];
19 yy = [1; 2; 3; 1; 2; 3];
20 inGf = f(xx,yy);
21
22 [X,Y] = meshgrid(x,y);
23 out = f(X,Y);
24
25 inM = [2, 3];
26
27 testCase.verifyEqual(reshapeToPlotMatrix(inGf, inM),out);
28 end
29
30 function test3D(testCase)
31 x = 1:2;
32 y = 1:3;
33 z = 1:4;
34
35 f = @(x,y,z) x + y*10 + z*100;
36
37 xx = [repmat(1, [12, 1]); repmat(2, [12, 1])];
38 yy = repmat([1; 1; 1; 1; 2; 2; 2; 2; 3; 3; 3; 3], [2, 1]);
39 zz = repmat([1; 2; 3; 4], [6, 1]);
40 inGf = f(xx,yy,zz);
41
42 [X,Y,Z] = meshgrid(x,y,z);
43 out = f(X,Y,Z);
44
45 inM = [2, 3, 4];
46
47 testCase.verifyEqual(reshapeToPlotMatrix(inGf, inM),out);
48 end