loop doesn't work
3 次查看(过去 30 天)
显示 更早的评论
Hello People :),
I have a 2464x220 matrix with 44 countries represented by 56 rows each and 5 columns each. I want to do some matrix mulitplication and sum the co2 emissions e11 +e21 in the end, but it calculates 44 times the same number(which is correct, but just for 1 country ) . It just gives me the first countries number and repeats it although i am trying to tell matlab to calcluate it for 44 different countries. I did the following:
kk=1:56:2464;
yy=1:5:220;
Co2_CB=ones([44,1]);
for j=kk
v=j+55;
r=yy;
q=r+4;
e11_j=sum(Q(j:v,r:q),'all');
e21_j=Q(1:2464,r:q);
e21_j(j:v,:)=[];
e21_j=sum(e21_j,'all');
Co2_CB(j)=e11_j+e21_j;
end
Co2_CB(Co2_CB==0)=[];
Co2_CB(Co2_CB==1)=[];
I dont understandt why matlab does not calculates the other 43 numbers.
Thanks in advance
采纳的回答
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!