필터 지우기
필터 지우기

Efficient Frontier code error

조회 수: 3 (최근 30일)
Alexandra
Alexandra 2015년 5월 12일
댓글: Alexandra 2015년 5월 12일
Hi, I am running the following code I found:
% portfolio0_efficient_frontier % Matlab program to plot efficient frontier and minimum % variance portfolio bmu = [.08;.03;.05] ; bOmega = [ .3 .02 .01 ; .02 .15 .03 ; .01 .03 .18 ] ; bone = ones(length(bmu),1) ; % Define vector of ones ibOmega = inv(bOmega) ; % Invert Omega ‐ "i" means inverse A = bone'*ibOmega*bmu ; B = bmu'*ibOmega*bmu ; C = bone'*ibOmega*bone ; D = B*C - A^2 ; bg = (B*ibOmega*bone - A*ibOmega*bmu)/D ; bh = (C*ibOmega*bmu - A*ibOmega*bone)/D ; % Compute minimum expected return and minimum return SD gg = bg'*bOmega*bg ; hh = bh'*bOmega*bh ; gh = bg'*bOmega*bh ; mumin = - gh/hh ; sdmin = sqrt( gg * ( 1 - gh^2/(gg*hh)) ) ; muP = linspace(min(bmu),max(bmu),50) ; % muP grid sigmaP = zeros(1,50) ; % Storage for i=1:50 ; omegaP = bg + muP(i)*bh ; sigmaP(i) = sqrt(omegaP'*bOmega*omegaP) ; end ; fsize = 16 ; ind = (muP > mumin) ; % Indicates efficient horizon ind2 = (muP < mumin) ; % Indicates locus below efficient horizon % Create plot ‐ efficient horizon is shown as a solid curve % ‐ the inefficient part of the locus is dashed figure(1) p1 = plot(sigmaP(ind),muP(ind),'-',sigmaP(ind2),muP(ind2),'--',sdmin,mumin,'.') ; % Change line widths, marker sizes, and colors for better appearance set(p1(1:2),'linewidth',4) ; set(p1(1:2),'color','blue') ; set(p1(3),'markersize',40) ; set(p1(3),'color','red') ; % Label axes xlabel('standard deviation of return','fontsize',fsize) ; ylabel('expected return','fontsize',fsize) ; set(gca,'xlim',[.25, .5]) ; set(gca,'ylim',[0.028, .08]) ; grid ; print portfolio03.ps - deps ;
And get the following error:
Attempted to access cur_arg(2); index out of bounds because numel(cur_arg)=1.
Error in checkArgsForHandleToPrint (line 40)
Error in print>LocalCreatePrintJob (line 336) handles = checkArgsForHandleToPrint(0, varargin{:});
Error in print (line 153) [pj, inputargs] = LocalCreatePrintJob(varargin{:});
Error in testefronteiraef (line 46) print portfolio03.ps - deps ;
What can I do?
Thank you very much

채택된 답변

David Sanchez
David Sanchez 2015년 5월 12일
Watch the last line of code:
print portfolio03.ps - deps ;
Mind the blank space right before deps
simply delete it:
print portfolio03.ps -deps
  댓글 수: 2
David Sanchez
David Sanchez 2015년 5월 12일
you can also write:
print(gcf,'-deps','portfolio03.ps')
Alexandra
Alexandra 2015년 5월 12일
It worked. Thanks a lot.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Portfolio Optimization and Asset Allocation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by