フィルターのクリア

exclude values of a matrix inside a for loop

1 回表示 (過去 30 日間)
mehra
mehra 2019 年 8 月 29 日
コメント済み: mehra 2019 年 9 月 2 日
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.

採用された回答

Jos (10584)
Jos (10584) 2019 年 8 月 29 日
you can replace the outliers by NaN before the loop and then use nanmax and nansum in your calculations
  1 件のコメント
mehra
mehra 2019 年 9 月 2 日
thanks

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by