There are a few easy ways to get the data from yahoo finance directly.
The following is the example for matlab code as your reference:
-----------
3. The matlab code:
%download stock data
nyseExcelName = 'NYSE.csv';
nasdaqExcelName = 'Nasdqa.csv';
[num, nyseText...