As an example I am taking the sum and average of a matrix x = [10 7 7 6 7 7 8 5 7 7]
I want to exclude the values 10 and 5 and try doing it as done in my code, but it doesn't seem to take the average correctly or the sum. Is there a way to fix my code to make it do this?
theSum = 0; for k = 1 : length(x); if k>5 && k<10 theSum = theSum + x(k); endendavg=theSum/8
Best Answer