Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
how to do this

Subject: how to do this

From: prabhu

Date: 7 Aug, 2010 10:23:05

Message: 1 of 3

i want all the b(i,j) values in 'm'
for i=1:4
     for j=1:4
         if(b(i,j)>e(i))
     m=sqrt(((d(i)-db)^2)-((db-d0)^2));
    if(((d(i)-d0)*(m))>e(i))
        m=b(i,j)
     end
 end
     end
 end

Subject: how to do this

From: ImageAnalyst

Date: 7 Aug, 2010 12:54:17

Message: 2 of 3

prabhu
I'm not exactly sure what you're doing with your code, but in general
to find "all the b(i,j) values in 'm' " you'd do something like this

% Create sample data.
b = [100.1, 200.2, 300.3; 402.1, 89.9 42.05]
m = [100, 200.2, 300.2,; 400, 89, 42]
% Extract out "matches"
yourTolerance = 0.15;
b_in_m = b(abs(m-b) < yourTolerance)

You use a tolerance because you're comparing floating point numbers.
In your case, you might use something small like eps or some multiple
of it.

You can also take a look at intersect() or ismember() but keep in mind
this (from the FAQ):
http://matlabwiki.mathworks.com/MATLAB_FAQ#Why_is_0.3-0.2-0.1_not_equal_to_zero_.28or_similar.29.3F


b =

  100.1000 200.2000 300.3000
  402.1000 89.9000 42.0500


m =

  100.0000 200.2000 300.2000
  400.0000 89.0000 42.0000


b_in_m =

  100.1000
  200.2000
  300.3000
   42.0500

Subject: how to do this

From: Roger Stafford

Date: 7 Aug, 2010 17:52:04

Message: 3 of 3

"prabhu " <kprabhucbe@gmail.com> wrote in message <i3jc68$kin$1@fred.mathworks.com>...
> i want all the b(i,j) values in 'm'
> for i=1:4
> for j=1:4
> if(b(i,j)>e(i))
> m=sqrt(((d(i)-db)^2)-((db-d0)^2));
> if(((d(i)-d0)*(m))>e(i))
> m=b(i,j)
> end
> end
> end
> end
- - - - - - -
  Can you please explain in detail what you mean by "all the b(i,j) values in 'm'". Your code doesn't make much sense - you are continually computing m and then writing over it. Can you please explain the significance of e(i), d(i), db, and d0? What is it you are actually trying to do?

Roger Stafford

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us