Skip to content

Instantly share code, notes, and snippets.

@ktripa
Created May 21, 2024 01:30
Show Gist options
  • Save ktripa/16d676c463ee9bc1ded9ec13728fcebb to your computer and use it in GitHub Desktop.
Save ktripa/16d676c463ee9bc1ded9ec13728fcebb to your computer and use it in GitHub Desktop.
%% PDSI TIME SERIES
df = readmatrix('PDSI_DATA_1901_2017.xlsx');
pdsi = df(:,2);
dates = num2str(df(:,1));
years = str2num(dates(:,1:4));
months = str2num(dates(:,5:6));
dates = datenum(years, months, 1);
% Plotting the sc-PDSI data
figure;
plot(dates, df(:,2), 'LineWidth', 2); % Plot with a thicker line for better visibility
hold on;
% Add a horizontal dashed line at the threshold
yline(-1, '--r', 'LineWidth', 1.5);
text(datenum(years(end), 6, 1), -1, ' Threshold -1', 'VerticalAlignment', 'bottom', 'Color', 'red');
xlabel('Year');
ylabel('sc-PDSI');
title('sc-PDSI Time Series Analysis');
datetick('x','yyyy');
axis tight;
grid on;
set(gcf, 'Color', 'w');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment