# explain this code if it is correct or not

Discussion in 'Programmer's Corner' started by sathya666, Nov 30, 2012.

1. ### sathya666 Thread Starter New Member

Nov 10, 2012
1
0
l=size(x)
s=1;
t2=1;
%ensegment=0;
for t=[4000:4000:l]
sum=0;
for t1=[s:t]
%sum=sum+(abs(x.^2));
s=sum+abs(x(t1)^2);
en(t2)=s;
end
%en(t2)=sum;
s=s+4000;
t2=t2+1;
%plot(en);
%ensegment=ensegment+1;
end
l1=size(en);
m1 = max(en);
for (i = 1:l1)
if en(i)== m1
break
end
end
sm = i;
%st = (max*4000)- 2000;
%end = st + 4000;
%yx = st:end
%plot(x(yx))
%stem(y,en)

2. ### tshuck Well-Known Member

Oct 18, 2012
3,531
675
No explanation for what you are trying to do? No explanation of what language this is? (I know it's MATLAB, but come on, help us help you!)

sathya666 likes this.
3. ### R!f@@ AAC Fanatic!

Apr 2, 2009
8,785
771
U say MATLAB ?

I see just typo's

4. ### WBahn Moderator

Mar 31, 2012
18,069
4,905
Since the only thing we have to go on is what you are telling it to do, then, yes, it is correct. It is doing exactly what you told it to do.

5. ### spinnaker AAC Fanatic!

Oct 29, 2009
5,062
1,160
It is beyond me how someone that is smart enough to learn to program is not smart enough to provide enough information so others can help them with a question.