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.

Help me understand Matlab code syntax

Status
Not open for further replies.

w_bwr

Member level 3
Joined
Feb 4, 2010
Messages
66
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
Karachi, Pakistan
Activity points
1,810
Code #1:

R_Freq1(R_Freq1>0) = +1;
R_Freq1(R_Freq1<0) = 0;


Code # 2:
if (R_Freq1>0)
R_Freq1=+1;
else if (R_Freq1<0)
R_Freq=0;
end

Do the above written code mean the same thing?
 

Re: Help in Matlab code!

is the R_Freq1 is a counter?
 

Re: Help in Matlab code!

if (R_Freq1>0)
R_Freq1=+1;
else
R_Freq1=0;
end
 

Re: Help in Matlab code!

No, code #1 and code #2 are different. The first one is referred to an array, the second one to a single variable.

In code #1 all the array is swept and if the cell content is > 0 the this value is substituted by +1, while if it is < 0 it is substituted by 0.

Example if at the beginning:

R_Freq1 = [-1 3 -5 7 -2 -8 4 9 -3]

at the end of code #1 the result will be:

R_Freq1 = [0 1 0 1 0 0 1 1 0]

the code #2 do the same work but applied to a single variable, not to an array.
 
  • Like
Reactions: Aya2002

    Aya2002

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top