comparison reshapeToPlotMatrixTest.m @ 162:c75c03f692b3 feature/grids

Moved function for resizing vectors out of grid.
author Jonatan Werpers <jonatan@werpers.com>
date Mon, 22 Feb 2016 13:34:50 +0100
parents +grid/funcToPlotMatrixTest.m@73bc43c7379e
children 51aaf67a7df5
comparison
equal deleted inserted replaced
161:73bc43c7379e 162:c75c03f692b3
1 function tests = funcToPlotMatrixTest()
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.funcToPlotMatrix(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(grid.funcToPlotMatrix(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(grid.funcToPlotMatrix(inGf, inM),out);
48 end