Table variable subscripts must be real positive integers

조회 수: 2 (최근 30일)
Eduardo Orellana
Eduardo Orellana 2021년 7월 29일
댓글: Eduardo Orellana 2021년 7월 30일
Using the data from https://la.mathworks.com/help/finance/black-litterman-portfolio-optimization.html, and running the code head(T(:,["Dates" benchmarkName assetNames])), get the following error: Table variable subscripts must be real positive integers, logicals, character vectors, or cell arrays of character vectors. I dont now how to fix it.
thanks
  댓글 수: 9
Dave B
Dave B 2021년 7월 29일
편집: Dave B 2021년 7월 29일
That helps, this sort of fits with my previous hypothesis i.e. that you need to provide char not string:
Let's work our way back to the final bit building off of:
head(T(:,'Dates'))
head(T(:,'DJI')) % just a different table variable
head(T(:,{'Dates' 'DJI'}) % Two table variables
% specifying 'DJI' in a workspace variable
benchmarkName = 'DJI';
head(T(:,{'Dates' benchmarkName}))
% specifying all of the assetNames
assetNames = {'AA' 'AIG' 'WMT' 'MSFT' 'BA' 'GE' 'IBM'};
head(T(:,assetNames))
% one way to put these all together
head(T(:,{'Dates' benchmarkName assetNames{:}}))
% the line of code from my previous comment
% (just in case something got confused and this works now)
head(T(:,['Dates' benchmarkName assetNames]))
Eduardo Orellana
Eduardo Orellana 2021년 7월 30일
It worked. Thank you Dave.

댓글을 달려면 로그인하십시오.

답변 (1개)

Eike Blechschmidt
Eike Blechschmidt 2021년 7월 29일
I guess you just forgot the quotation marks around benchmarkName and assetNames.

카테고리

Help CenterFile Exchange에서 LMI Solvers에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by