exclude values of a matrix inside a for loop
조회 수: 2 (최근 30일)
이전 댓글 표시
Hello
what should I include in my for loop so that it can ignore some data in my matrixes?
my code is like:
xler=cumsum([1/3 1/3 1/3 0.5 0.5 0.5 0.5 0.5 0.5 1 1 2 1.27])*D;
z=zeros(8,13);
k=zeros(8,13);
K=zeros(1,13);
K_ave=zeros(1,13);
for n=1:13
z(:,n)=results(results(:,1)==xler(n),3);
k(:,n)=results(results(:,1)==xler(n),10);
K(:,n)=sum((k(2:end,n)+k(1:end-1,n))./2.*(z(2:end,n)-z(1:end-1,n)));
K_ave(n)=K(:,n)./max(z(:,n));
end
some arrays are outliers and I dont want to use them in my calculations; outliers are: z(1,13) and k(1,13)
when I include
z(1,13)=[];
k(1,13)=[];
in my codes it gives the error:
A null assignment can have only one non-colon index.
댓글 수: 0
채택된 답변
Jos (10584)
2019년 8월 29일
you can replace the outliers by NaN before the loop and then use nanmax and nansum in your calculations
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!