For loop simple problem
이전 댓글 표시
i want to run this very simple for loop but the only result is a totally wrong chart and the message : " Unable to perform assignment because the indices on the left side are not compatible with the size of the right side" what does it mean ? how can solve this problem?
for i= 0.01:0.02:0.99
W1_t=i;
W2_t=1-i;
R_t=W1_t*mean(R_2(:,1))+W2_t*(R_2(:,2));
vp_t=W1_t^2*var(R_2(:,1))+W2_t^2*var(R_2(:,2))+2*W1_t*W2_t*c(2,1);
s_t=sqrt(vp_t);
figure(2)
L(1)=plot(s_t,R_t,'bx','Markersize',7);
hold on
xlim([0 5])
ylim([0 0.3])
end
답변 (1개)
Walter Roberson
2019년 5월 6일
0 개 추천
Your s_t is a scalar. Your R_t is a vector. plot is creating a vector of line handles, one for each element in R_t. That vector does not fit inside L(1)
카테고리
도움말 센터 및 File Exchange에서 Financial Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!