Hi Folks,

I am new to this forum as I created an account because I have taken on an endeavor to reacquaint myself with math and programming. As such, I am working on a fairly simple task but can't seem to figure it out.

I am importing data from a comma deliminated file via the 'textscan' function. By default, this function stores the scraped data into a cell array. Two of the fields that I am importing are YEAR and MONTH, for which I then want to use as input into the 'nweekdate' function to compute a vector of the date of the 3rd Friday of each MONTH/YEAR combination that is present in the data.

My code is as follows:

fid = fopen(fileName);

yearMonth = textscan(fid,'%f32 %s %*[^\n]', 'headerlines', 3);

% the 'yearMonth' array is a 1x2 cell array. Each cell then has an

% embedded cell array of size 1700x1

% %f32 = year = 2 digit year (for 2010 the value is 10)

% %s = month = 3 letter string representing the month (for January = Jan)

% the 'nweekdate' function doesnt seem to accept cell data so I convert

% the year, which is in the first cell of the yearMonth array to a matrix below

year2 = cell2mat(yearMonth(:,1)) + 2000;

% now I want to convert the 3 letter string representing the month to a

% number between 1-12 where Jan = 1. For example I have just included

% the code to convert 'Jan' to 1.

monthIndex = find(strcmp('Jan', yearMonth(:,2)));

newMonthMatrix(monthIndex,:) = 1;

When I run the program I get an empty 'monthIndex' matrix, even though I know the second cell in the 1x2 yearMonth array has an 1700x1 embedded cell array with string values equal to 'Jan'.

Maybe there is a more elegant solution to what it is that I aspire to achieve because I will have to write the the last 2 lines of code 12 times to convert each month string to a number.

Appreciate the help.