Info

This question is closed. Reopen it to edit or answer.

How to add the value of elements that have a value that is more than a certain boundary value in the vector automatically?

1 view (last 30 days)
I don't know how to add value of my vector automatically. However I have two cluster for 'y' vector. That are the element of y less than 10 and the elements of y more than 10. This is the cluster code
yrendah=sum(y(:) <= 10);
ytinggi=sum(y(:) > 10);
In my algorithm, after I find the value of 'sx', I will update the value of 'y'. Where each element of 'y' which has a value of more than 10 will be added to the value of 'sx'. And for the element 'y' which has a value of less than 10 does not change. How do I add up each 'y' element that has a value of more than 10 with 'sx'?. This is my full code
clc;
clear all;
T=readtable('EVASUSANTIDATA.xlsx');
x1=T.PENDAFTARAN;
x2=T.TUNDA;
x3=T.KUOTA;
y=T.LAMA;
yn=length(y);
yrendah=sum(y(:) <= 10);
ytinggi=sum(y(:) > 10);
for i=1:yn
if y(i)<=10
c=x3(i);
while y(i)<=10
c=c-1;
y(i)=(x1(i)+x2(i))/(c);
end
if y(i)>=10
y(i)=(x1(i)+x2(i))/(c+1);
end
d=c+1;
k(i)=x3(i)-d;
end
end
sx=round(sum(k)/ytinggi);
sxx=rem(sum(k),ytinggi);
  3 Comments

Answers (1)

David Hill
David Hill on 28 Mar 2020
y(ismember(y,maxk(y,8)))=y(ismember(y,maxk(y,8)))+sx;

Products

Community Treasure Hunt

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

Start Hunting!