How do I specify variable names in Matlab?
조회 수: 1 (최근 30일)
이전 댓글 표시
I have a portfolio of 10 stocks on an excel spreadsheet and have the names of the stocks in the first row. I can import this to Matlab by defining my data as a numeric matrix as opposed to a column vector. This allows me to calculate the variance-covariance matrix, which I was unable to do by importing the spreadsheet as a column vector.
The problem now is that I now cannot specify that my first row is variable names. Does anyone have any advice? I would be most grateful for your help. Thank you!
댓글 수: 1
채택된 답변
Walter Roberson
2016년 1월 27일
[num, txt] = xlsread('YourXLSFile.xls');
Then the numbers are in num and the variable names are in txt.
댓글 수: 2
Walter Roberson
2016년 1월 27일
p = Portfolio('AssetList', txt(:).', 'RiskFreeRate', CashRet);
I do not know for sure that the cell array needs to be a row vector, but that is what I see in the examples.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!