Hello, my if statements within my for loop does not work appropiate. When i'm printing the x-vector to the screen, the maximum value is sadly 25000 in x(i)
The counter only reach 1, but i'll like to count further if the condition name(i) & name1(i) holds. Name and name1 are also vectors with dimensions 100×1. Another concern is for instance when printing name(1) and name1(1) to the screen I've seen that the counter, op, runs despite that name1(1) is <10. Is the && command wrong?
x = zeros(100,1); %Preallocation
name1 = randi(30,100,1) %vector
name = randi(([0 1], 100,1) %vectorop=0; %counter index
for i=1:length(x)if name(i)==1 && name1(i)>=10 op=op+1; %counter
else if op~=0; if 0<op<=1; x(i)=x(i)+25000; elseif 1<op<=2; x(i)=x(i)+75000; elseif 2<op; x(i)=x(i)+200000; end op=0; end endend
Best Answer