Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Truncation of elements in MATLAB Array

Status
Not open for further replies.

pancho_hideboo

Advanced Member level 5
Advanced Member level 5
Joined
Oct 21, 2006
Messages
2,847
Helped
767
Reputation
1,536
Reaction score
733
Trophy points
1,393
Location
Real Homeless
Activity points
17,490
I would like to set zero for elements whose absolute is lesser than 10 in MATLAB Array.

Now I use following MATLAB code for this purpose.
However this is not cool.
Is there any cool method ?
Code:
>> A=[1000, 200, 3, 10]

A =

        1000         200           3          10

>> for(i=1:length(A))
if abs(A(i)) < 10, A(i)=0; end
end
>> A

A =

        1000         200           0          10

>>
 

Code:
octave> A=[1000, 200, 3, 10]
A =

   1000    200      3     10

octave> A=A.*(abs(A)>=10)
A =

   1000    200      0     10
 

Code:
>> A=[1000, 200, 3, 10]

A =

        1000         200           3          10

>> A( find(abs(A) < 10) ) = 0;
>> A

A =

        1000         200           0          10

>>
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top