Mercurial > repos > public > sbplib
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/reshapeToPlotMatrixTest.m Mon Feb 22 13:34:50 2016 +0100 @@ -0,0 +1,48 @@ +function tests = funcToPlotMatrixTest() + tests = functiontests(localfunctions); +end + +function test1D(testCase) + inGf = [1 2 3 4 5]'; + inM = 5; + out = [1 2 3 4 5]'; + testCase.verifyEqual(grid.funcToPlotMatrix(inGf, inM),out); +end + +function test2D(testCase) + x = 1:2; + y = 1:3; + + f = @(x,y) x + y*10; + + xx = [1; 1; 1; 2; 2; 2]; + yy = [1; 2; 3; 1; 2; 3]; + inGf = f(xx,yy); + + [X,Y] = meshgrid(x,y); + out = f(X,Y); + + inM = [2, 3]; + + testCase.verifyEqual(grid.funcToPlotMatrix(inGf, inM),out); +end + +function test3D(testCase) + x = 1:2; + y = 1:3; + z = 1:4; + + f = @(x,y,z) x + y*10 + z*100; + + xx = [repmat(1, [12, 1]); repmat(2, [12, 1])]; + yy = repmat([1; 1; 1; 1; 2; 2; 2; 2; 3; 3; 3; 3], [2, 1]); + zz = repmat([1; 2; 3; 4], [6, 1]); + inGf = f(xx,yy,zz); + + [X,Y,Z] = meshgrid(x,y,z); + out = f(X,Y,Z); + + inM = [2, 3, 4]; + + testCase.verifyEqual(grid.funcToPlotMatrix(inGf, inM),out); +end \ No newline at end of file