# Array indices must be positive integers or logical values.

조회 수: 1(최근 30일)
Lorenzo Reda 2021년 3월 14일
답변: Star Strider 2021년 3월 14일
Pls tell me where is the error.
for i= 0.01:0.02:0.99
w1_temp= i;
w2_temp= 1-i;
Rp_temp= w1_temp*mean(R_2(:,1))+w2_temp*mean(R_2(:,2));
Sp_temp= sqrt((w1_temp^2)*var(R_2(:,1))+(w2_temp^2)*var(R_2(:,2))...
+2*w1_temp*w2_temp*C(2,1));
figure(5)
L(1)=plot(Sp_temp,Rp_temp,'bx','MarkerSize',7);
hold on
xlim([0 2]);
ylim([0 0.12]);

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

### 답변(2개)

ii = 0.01:0.02:0.99;
w1_temp= ii;
w2_temp= 1-ii;
Rp_temp= w1_temp*mean(R_2(:,1))+w2_temp*mean(R_2(:,2));
Sp_temp= sqrt((w1_temp.^2)*var(R_2(:,1))+(w2_temp.^2)*var(R_2(:,2))...
+2*w1_temp.*w2_temp*C(2,1));
figure(5)
plot(Sp_temp,Rp_temp,'bx','MarkerSize',7);
xlim([0 2])
ylim([0 0.12])
##### 댓글 수: 0표시숨기기 이전 댓글 수: -1

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

Star Strider 2021년 3월 14일
Not able to run the posted code:
Unrecognized function or variable 'R_2'.
That aside, be absolutely certain that you have not created variables named ‘mean’, ‘sqrt’, ‘var’, ‘plot’. ‘xlim’,’ylim’ or ‘C’, since creating those variables would throw the (unposted object) error.