Hi Devendra,
From what I understand, you are trying to extract specific phenological values from an NDVI time series using MATLAB.
For this you can refer to the following steps and the attached code snippets:
You can start by importing your NDVI data from the CSV file into MATLAB and then extract the dates and the NDVI values from the dataset.
data = readtable('ndvi_time_series_input.csv');
dates = data.Properties.VariableNames(2:end);
ndvi_values = data{:, 2:end};
Initialize the arrays using ‘NaT’ function in MATLAB, to store the desired results.
sos = zeros(size(ndvi_values, 1), 1);
pos = zeros(size(ndvi_values, 1), 1);
eos = zeros(size(ndvi_values, 1), 1);
pos_value = zeros(size(ndvi_values, 1), 1);
avg_sum = zeros(size(ndvi_values, 1), 1);
max_sum = zeros(size(ndvi_values, 1), 1);
base = zeros(size(ndvi_values, 1), 1);
Calculate the phenological markers by looping through each row of the NDVI data.
for i = 1:size(ndvi_values, 1)
[pos_value(i), pos_idx] = max(ndvi_values(i, :));
pos(i) = datenum(dates{pos_idx}, 'yyyymmdd');
sos_idx = find(ndvi_values(i, :) > (min(ndvi_values(i, :)) + 0.1 * (pos_value(i) - min(ndvi_values(i, :)))), 1);
sos(i) = datenum(dates{sos_idx}, 'yyyymmdd');
eos_idx = find(ndvi_values(i, pos_idx:end) < (min(ndvi_values(i, :)) + 0.1 * (pos_value(i) - min(ndvi_values(i, :)))), 1);
eos(i) = datenum(dates{pos_idx + eos_idx - 1}, 'yyyymmdd');
avg_sum(i) = sum(ndvi_values(i, :)) / length(ndvi_values(i, :));
max_sum(i) = sum(max(ndvi_values(i, :)));
base(i) = range(ndvi_values(i, :));
Compile these calculations into a table for easy analysis and interpretation and display the results.
results = table(data{:, 1}, sos, pos, eos, pos_value, avg_sum, max_sum, base, ...
'VariableNames', {'Location', 'SOS', 'POS', 'EOS', 'POS_Value', 'Avg_Sum', 'Max_Sum', 'Base'});
You can look at the output for a better understanding:
For more details on the ‘NaT’ or ‘datenum’ functions in MATLAB, you can refer to the following links:
Happy coding!