mercredi 18 novembre 2020

Substracting a number from certain section of the array

I have a number series 8654 elements having data in format (degree) as follows (just an example):

A = [ 1.002 2.003 3.004 4.005 339.006 341.007 342.008 343.009 1.002 2.003 3.004 4.005];

I am currently using the following code-MATLABR2020a to make elements in the above array having values more than 300 subtracted by 360;

if (A(:,1) > 300)
    
    A(:,2)= 360-A(:,1);
    
else
    A(:,2) = A(:,1);
end

to make a new array in the second column which looks like

A = [ 1.002 2.003 3.004 4.005 21 19 18 17 1.002 2.003 3.004 4.005];

But I am getting the same array as

A = [ 1.002 2.003 3.004 4.005 339.006 341.007 342.008 343.009 1.002 2.003 3.004 4.005];

I don't know which place I am going wrong !! Guidance required !!

Aucun commentaire:

Enregistrer un commentaire