diff +grid/evalOn.m @ 275:3ea2ae2a3d15 feature/beams

Improvments to eval on grids. Added function to extrac components of a vector gf.
author Jonatan Werpers <jonatan@werpers.com>
date Tue, 06 Sep 2016 17:28:11 +0200
parents ac8e00883986
children 30321dc180e1
line wrap: on
line diff
--- a/+grid/evalOn.m	Tue Sep 06 15:54:45 2016 +0200
+++ b/+grid/evalOn.m	Tue Sep 06 17:28:11 2016 +0200
@@ -17,14 +17,10 @@
     % func should now be a function_handle
 
     % Get coordinates and convert to cell array for easier use as a parameter
-    x = g.points();
-    X = {};
-    for i = 1:size(x, 2)
-        X{i} = x(:,i);
-    end
+    x = num2cell(g.points());
 
     % Find the number of components
-    x0 = num2cell(x(1,:));
+    x0 = x(1,:);
     f0 = func(x0{:});
     k = length(f0);
 
@@ -32,8 +28,11 @@
         error('grid:evalOn:VectorValuedWrongDim', 'A vector valued function must be given as a column vector')
     end
 
-    gf = func(X{:});
-    if  k > 1  % Reorder so that vectors sit together.
-        gf = reshape(reshape(gf, [g.N, k])', [g.N*k, 1]);
+    gf = zeros(g.N*k, 1);
+    % keyboard
+    for i = 1:g.N
+        % (1 + (i-1)*k):(i*k)
+        % func(x{i,:})
+        gf((1 + (i-1)*k):(i*k)) = func(x{i,:});
     end
 end
\ No newline at end of file