I have a temperature monthly netcdf gridded data 1980-2021; and csv contains anomalies data that is not gridded ;can i create a correlation betwen them?

3 views (last 30 days)
I have a temperature monthly netcdf gridded data 1980-2021; and csv contains anomalies data that is not gridded ;can i create a correlation betwen every single grid for every month with the csv data? Thanks in advance

Answers (1)

Shlok
Shlok on 26 Feb 2025
Hi Mohamed,
Yes, you can create a correlation between your gridded NetCDF temperature data and the non-gridded anomaly data (CSV), given that both datasets cover the same time-period and spatial resolution. To do this, follow the following steps:
  • Load the NetCDF data using MATLAB's "ncread" function and CSV data using "readtable" or "csvread" function.
  • If data does not cover the same time-period, then interpolate the anomaly data to match the grid of the NetCDF data. Functions such as "interp1" can be used to perform this task.
anomalies_interpolated = interp1(time_from_csv, anomalies, time_from_netcdf);
  • Now use the MATLAB functions like "corrcoef" to calculate the correlation between the datasets.
correlation_matrix = corrcoef(temperature_from_netcdf(:), anomalies_interpolated(:));
Hence following the above steps, we can obtain the desired correlation.
To know more about the functions mentioned above, refer to the following MathWorks Documentation link:
Hope it helps.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!