Hi Arindam,
I understand that you have data for 180 (15x12) locations, about a trend for 163 years in the form of a 3-D matrix and wish to plot the trend at different locations.
Here are some steps that can be followed to achieve the plot:
- Use “squeeze” function to get the trend values for different years over the different latitude and longitude values.
- Use polynomial fitting using “polyfit” function to calculate the value of trend over the years.
- Create a mesh-grid for latitude and longitude.
- Plot the required trend.
Below is a sample code that performs the above discussed step taking random data to generate a similar plot.
data = rand(lat, lon, time);
[latSize, lonSize, timeSize] = size(data);
trends = zeros(latSize, lonSize);
timeseries = squeeze(data(lat, lon, :));
p = polyfit(timeValues, timeseries, 1);
[lonGrid, latGrid] = meshgrid(1:lonSize, 1:latSize);
surf(lonGrid, latGrid, trends);
Please refer the shared documentation link for more information:
- squeeze: https://www.mathworks.com/help/matlab/ref/squeeze.html
- polyfit: https://www.mathworks.com/help/matlab/ref/polyfit.html
- meshgrid: https://www.mathworks.com/help/matlab/ref/meshgrid.html
- surf: https://www.mathworks.com/help/matlab/ref/surf.html
I hope this helps to plot the required data.
HTH