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
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!

Translated by