1

I'm trying to perform DWT and make a 3D plot using Wavelet Analysis with Multi-resolution analysis (MRA) on a 1-D signal.

In short, MRA will take a discrete sampled set of data and run wavelet analysis on it.

Each pass produces 1/2 the samples of the previous run. I end up with an X by Y matrix with an amplitude stored in each value. X is the number of samples (or time), and Y is the "detail" wavelet result. The matrix of data might look something like this:

[ 1 1 1 1 2 4 8 2 1 1 1 1 2 1 1 2 ]
[ 1 . 1 . 3 . 6 . 1 . 1 . 2 . 1 . ]
[ 1 . . . 3 . . . 1 . . . 2 . . . ]
[ 1 . . . . . . . 1 . . . . . . . ]

The '.' would be NaN or 0 or possible something else (I assume I'm doing something wrong).

I want to produce a plot like so:

enter image description here

It doesn't seem like Matlab can interpolate that much data in a graph. I've tried meshgrid, surf, ribbon, plot3, etc - but it requires all vectors to be the same length. Putting NaN or 0 results in un-reliable results.

The best I've done so far is to use ribbon to represent the data as strips - but that also has issues in the data it is representing.

I've done my best to read through the help pages in Matlab but haven't made much progress. Can someone push me in the correct direction?

Another update for November 2012 High-density surf plot will appear entirely black due to the meshgrid edge color. To disable it, use the following function: surf(zi, 'EdgeColor', 'none');

Update with adjustment I'm still not convinced this is the final solution, but here is my best effort at producing a heatwave like 3D plot of random data. Whether this will help me realize my signal data is another story.

% initialize the matrix of sampled data
indx = 1;
data = NaN(5, 128);
for row=1:5
    for col=1:128
        if ( mod(col-1, indx) == 0)
            data(row, col) = rand();
        end
    end
    indx = power(2, row);
end

% Linearize the data in each row to overcome NaN entries
for row=1:5
    fprintf('Linear interpolation for row %d\n', row); 
    indx = NaN;
    for col=1:128
        if (data(row, col) ~= NaN) || (col == 128)
            if isnan(indx)
                % initalize first point
                indx = col;
            elseif isnan(data(row,col)) && (col ~= 128)
                % ignore NaN values between 1 and N-1
            elseif ((col-1) ~= indx)
                fprintf('Creating linspace from col=%d to indx=%d\n', col, indx)
                if (col == 128)
                    % first row will always contain all points
                    v = linspace(data(row, indx), data(1, col), col+1-indx);
                else
                    v = linspace(data(row, indx), data(row, col), col+1-indx);
                end
                i=1;
                for j=indx:col
                    data(row,j) = v(i); % update our data
                    i = i + 1; % increment counter
                end
                indx = col;
            elseif ((col-1) == indx)
                indx = NaN;
            end
        end
    end
end

% Populate the X and Y vectors, X is columns, Y is rows, Z is data
xmin = 1;
ymin = 1;
xmax = 128;
ymax = 5
[X, Y] = meshgrid(1:5, 1:128);

[xi, yi] = meshgrid(.1:.1:5, 0:.5:128);
zi = griddata(X, Y, data.', xi, yi);
surf(zi);
% disable edge color for high density plots (or it will look solid black)
surf(zi, 'EdgeColor', 'none');

Random Discrete 3D Plot using linearization

Cookster
  • 1,463
  • 14
  • 21
  • Usually there should be no problem in plotting the data if it is available in an X by Y matrix. Maybe it is helpful if you post the code you used for plotting? – H.Muster Oct 02 '12 at 06:54
  • Sure - let me write a mock up later tonight as the original data set is a bit to large. – Cookster Oct 02 '12 at 16:48
  • I guess I'm not entirely sure what is best suited, surf, mesh, etc. I suspect surf is not what I want and I don't fully understand how the linspace and resolution impact the outcome. – Cookster Oct 03 '12 at 19:47
  • 1
    Why don't you just use `imagesc` to create a heatmap-like display? – H.Muster Oct 04 '12 at 06:17
  • Ah, I will try that, I was not aware of imagesc! It was going to be my next question, thanks. – Cookster Oct 04 '12 at 14:49
  • I guess another question to ask is: is it accurate to linearize my data in such a way when doing Multi-resolution decomposition with wavelet analysis? Or maybe that is dependent on the nature of the signal being analyzed. As I review the analysis, I feel this is, at best, an approximation and poor one at that. Perhaps 3D heat wave mapping isn't suitable for MRA and I should focus on 2D signal analysis to present my findings. – Cookster Oct 08 '12 at 06:52

0 Answers0