Stor data in a vector
    조회 수: 9 (최근 30일)
  
       이전 댓글 표시
    
For every loop z i want to store my data so that JJ doesnt just become the reslut of z=40, i want JJ to be a vector(1,1000), now i only get JJ to be a vector of (1,25) from the last z loop.
p_t2=1:1000 pt2=1:40
for z=1:40 for v=1:25 XX=p_t2(v)./pt2; JJ(v)=sum(XX); end p_t2(1:25)=[]; pt2(:,1)=[]; end
thank you in advance
댓글 수: 0
채택된 답변
  Iman Ansari
      
 2013년 6월 5일
        p_t2=1:1000 
pt2=1:40
JJ=[];
for z=1:40 
    for v=1:25 
        XX=p_t2(v)./pt2; 
        JJ=[JJ sum(XX)]; 
    end
    p_t2(1:25)=[]; 
    pt2(:,1)=[]; 
end
추가 답변 (3개)
  Lukas
 2013년 6월 5일
        댓글 수: 1
  Iman Ansari
      
 2013년 6월 5일
				clear;
p_t2=rand(2,1000);
pt2=rand(2,40);
JJ=[];
for z=1:40 
    for v=1:25 
        XX=bsxfun(@rdivide,p_t2(:,v),pt2); 
        JJ=[JJ sum(XX,2)]; 
    end
    p_t2(:,1:25)=[]; 
    pt2(:,1)=[]; 
end
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


