exclude values of a matrix inside a for loop
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Jos (10584)
le 29 Août 2019
you can replace the outliers by NaN before the loop and then use nanmax and nansum in your calculations
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!