bk sumedha
bk sumedha

Reputation: 63

How to use of plus/minus together in matlab

I have a if loop where i need to check the condition.The loop is like this:

if(tht(1)==thf(1))
      S='Original Note';  
  display(S);
else
          S = 'Fake Note';  
         display(S);
end

Inside that if loop i want to place that ±. How can it can be done? For example like:

if(tht(10)==thf(10±5))

How this is possible? how both the symbol of plus and minus can be used together in matlab?

Upvotes: 0

Views: 8084

Answers (2)

Sam Roberts
Sam Roberts

Reputation: 24127

The symbol ± has no meaning in MATLAB. You will need to use

if tht(10)==thf(10+5) || tht(10)==thf(10-5)

Upvotes: 2

il_raffa
il_raffa

Reputation: 5190

A possible solution to have something similar to:

if(tht(10)==thf(10±5))

could be:

idx=10
idx_p=idx+5
idx_m=idx-5

if(sum(tht(idx)==thf([idx_m idx_p])))
   disp('verified')
else
   disp('not verified')
end

Hope this helps.

Upvotes: 0

Related Questions