exclude values of a matrix inside a for loop
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
mehra
el 29 de Ag. de 2019
Comentada: mehra
el 2 de Sept. de 2019
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 comentarios
Respuesta aceptada
Jos (10584)
el 29 de Ag. de 2019
you can replace the outliers by NaN before the loop and then use nanmax and nansum in your calculations
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!