Getting Matlab to call a string
I'm working on this program which involves a CSV file of Apple's Stock from the last ten years. It is composed of ten tasks. Task 1 wants me to find what the stock's highest ever closing price was and when did it occur. The answer should be
“This stock's highest ever closing price was $215.04, which occurred on 19-Jan-10”
The variables open, hi, lo, close, and vol are vectors and the variable date is a cell array.
Now we have to make Matlab read data from this CSV file. Here is the coding I have so far
[date,open,hi,lo,close,vol] = textread('apple.csv','%s%f%f%f%f%f','delimiter',', ','headerlines',1);
highclose = max(close);
fprintf('This stocks highest ever closing price was $%.2f, which occurred on %s \n',highclose)
fprintf('\n')
I have no idea how to get the date to display. I cannot simply just make a variable for the date though. Such as, I cannot make time=date{9} and insert it into the fprintf code to get 19-Jan-10 to display.
This is because if my program were to read different data, it would get the highest closing price correct because "highclose=max(close)" will choose the highest number regardless if new data is loaded but then my date would be incorrect.
Can anyone aid me please?