Hi,
I have asked one question regarding a simple decrement of an array yesterday and got a good response. Today i am trying to manipulate that array further but i am kind of stuck in between loops and condtions. I am new to Matlab
It goes like this i am trying to decrement an array and once any particular element of that array arrives at zero, i am assigning that element as well as its immediate neighboring element with some value. What i need is that once that assigned value arrives at zero, it will increase the counter value by 1.
close all
clear all
clc
n = [11 12 13 24 3 7 14 11 12];
n_indx = zeros(1,12);
recv_count = 0;
send_count = 0;
send_count_1 = zeros(1,12);
recv_count_1 = zeros(1,12);
for i=1:40
while any(n)
n = max(0,n-1)
n_indx = find(n==0)
n(n_indx) = 3 ;
send_count_1(n_indx)=send_count+1 ;
if (n(n_indx+1)>0)
n(n_indx+1)=3
if (n(n_indx-1)>0)
n(n_indx-1)=3
if (n(n_indx)==0) && (n(n_indx+1)==0) && (n(n_indx-1)==0)
recv_count_1(n_indx+1)=recv_count+1;
recv_count_1(n_indx-1)=recv_count+1;
break
end
end
end
end
end