The strategy that you have described using "immse" function can be useful for comparison. Some other things to consider are:
- Does the data need to be pre-processed and normalized?
- Are the time and frequency ranges identical and can they be ignored for the comparison?
For comparing images or 2D matrices, you can also use "psnr" or "ssim". Refer to the example below for usage of "ssim", I have taken some example data with different time and frequency. Interpolation can be ignored if the ranges are identical.
% Dataset 1
frequency1 = linspace(0, 400, 100); % 100 points from 0 to 400
time1 = linspace(0, 0.5, 50); % 50 points from 0 to 0.5
[FreqGrid1, TimeGrid1] = meshgrid(frequency1, time1);
Power1 = sin(FreqGrid1 / 100.0) .* cos(TimeGrid1 * 4 * pi);
% Dataset 2 with different ranges
frequency2 = linspace(0, 500, 120); % Different range and number of points
time2 = linspace(0, 0.6, 60); % Different range and number of points
[FreqGrid2, TimeGrid2] = meshgrid(frequency2, time2);
Power2 = sin(FreqGrid2 / 120.0) .* cos((TimeGrid2 * 5 * pi) + pi / 8);
% Interpolate Dataset 2 to match the grid of Dataset 1
Power2Interpolated = interp2(FreqGrid2, TimeGrid2, Power2, FreqGrid1, TimeGrid1, 'linear');
% Calculate SSIM between the original Power1 and the interpolated Power2
[ssimval, ssimmap] = ssim(Power1, Power2Interpolated);
fprintf('The SSIM value is %0.4f\n', ssimval);
% Optionally, visualize the SSIM map
figure;
imshow(ssimmap, []);
title(sprintf('SSIM Index Map - Mean SSIM Value: %0.4f', ssimval));
You can refer to the following documentation link for more information:
- https://www.mathworks.com/help/images/ref/ssim.html
- https://www.mathworks.com/help/images/ref/psnr.html
Hope this helps!