help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: error in looping


From: marco atzeri
Subject: Re: error in looping
Date: Mon, 28 Jan 2013 21:20:40 +0100
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130107 Thunderbird/17.0.2

On 1/28/2013 8:59 PM, febty febriani wrote:
Hi everyone,

My original code like below :

A1=A(:,1);
[a1 index1]=min(abs(A1-10000));
C1=A(index1,:);

A2=A(:,1);
[a2 index2]=min(abs(A2-1000));
C2=A(index2,:);

A3=A(:,1);
[a3 index3]=min(abs(A3-100));
C3=A(index3,:);

A4=A(:,1);
[a4 index4]=min(abs(A4-10));
C4=A(index4,:);

A5=A(:,1);
[a5 index5]=min(abs(A5-1));
C5=A(index5,:);

A1 to A5 are copied of A first rows

C=[C1;C2;C3;C4;C5];
save -ascii $ofile15 C;

I want to make them in a looping. My code code for this purpose is below :

for i=1:5;
  A(i)=A(:,1);

you are using A for two different objects
Use another identifier

  [a(i) index(i)]=min(abs(A(i))-(10^(n-i)));
  C(i)=zeros(size(A));
  C(i)=A(index(i),:);
end

C=[C1;C2;C3;C4;C5];
save -ascii C.dat C;

However, the error message appeared : error: A(I) = X: X must have the
same size as I.

I have no clue how to fix it. Does anyone can help me? Thanks very much
in advance.

Regards,
Fety


Regards
Marco




reply via email to

[Prev in Thread] Current Thread [Next in Thread]