I cant seem to find where you get variables SWI and P from, so make sure these are accessible to the function somehow.
Below is a brute force way of reading all (365?) files in a specific folder and feeding them through your algorithm one by one.
Hope this helps!
% Location of files to be read
folder = 'C:\foo\siffer\second try\';
% Type of files to read. Leave as '' if you wish any ending.
ending = 'tiff';
% Find all files in that folder
files = dir(folder);
numFiles = length(a);
el = length(ending);
% Loop through all found files
for i = 1:numFiles
filename = files(i).name;
nameLength = length(filename);
% Ignore files with improper filename
if nameLength<el+1
% Not enough letters for containing .tiff
continue
elseif strcmp(filename(nameLength + (-el+1:0)) , ending)
% The file indeed has the right format
% Either just call your function here
% % output=Input(data,T);
% or paste the content of the
% function like i did :
[x,cmap]=imread([folder,filename]);
data=im2double(x);
ID_notNaN=find(~isnan(SWI));
D=data(:,1);
X=data(:,2);
F=nan(length(data(:,1)),1);
P(ID_notNaN)=SWI;
output=[data(:,1),data(:,2)];
end
end