ddd.m 1.61 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
classdef ddd < export.Data
    %DDD export 3D data
    %   
    
    properties
        x;
        y;
        z;
        xRange;
        yRange;
    end

    properties(Dependent)
       out; 
    end
    
    methods
        
        function obj = ddd(varargin)
           obj@export.Data('N', 60); 
           
           for arg=1:2:length(varargin)
               obj.(varargin{arg}) = varargin{arg + 1}; 
           end
           
        end
        
        function xR = get.xRange(obj)
           if isempty(obj.xRange)
              xR = [obj.x(1), obj.x(end)]; 
           else
               xR = obj.xRange;
           end
        end
        
        function yR = get.yRange(obj)
           if isempty(obj.yRange)
              yR = [obj.y(1), obj.y(end)];
           else
               yR = obj.yRange;
           end
        end
        
        function set.z(obj, z)
           obj.z = squeeze(z); 
        end
        
        function out = get.out(obj)
            o.x = linspace(obj.xRange(1), obj.xRange(2), 60);
            o.y = linspace(obj.yRange(1), obj.yRange(2), 60);
            [o.x, o.y] = meshgrid(o.x, o.y);
            [grid.x, grid.y] = meshgrid(obj.x, obj.y);
            o.z = interp2(grid.x, grid.y, obj.z', o.x, o.y);
            out = [o.x(:), o.y(:), o.z(:)];            
        end

        function i = isempty(obj)
            i = isempty(obj.x) || isempty(obj.y) || isempty(obj.z);
        end
        
    end

    methods( Access = protected)
       function innerexport(obj)
            o = obj.out;
            save(obj.path, 'o',  '-ascii', '-tabs')
        end         
    end
    
    
end