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:
matrix function that compare a list of real numbers with a real number

Subject: matrix function that compare a list of real numbers with a real number

From: felix

Date: 19 Nov, 2012 11:20:14

Message: 1 of 4

I need a function which accepts as input a list of real numbers, and a real number X and which returns to the output:
• The number of how many times the number (X) appear in the table
• The location where this number appears in the table
• A table that will have the value 0 in the positions where (X) appears and the value -1 in the remaining positions
• A table(matrix) where the elements of the original matrix that is larger than the input number (X) will be replaced with the maximum number of the original table
• A vector which will contain all the unique elements of the input table which are larger than the number(X) we gave to the entrance.

Subject: matrix function that compare a list of real numbers with a real number

From: felix

Date: 19 Nov, 2012 12:07:10

Message: 2 of 4

some help here please.... :/

Subject: matrix function that compare a list of real numbers with a real number

From: Jos (10584)

Date: 20 Nov, 2012 09:09:08

Message: 3 of 4

"felix " <f_3lix@hotmail.com> wrote in message <k8d4le$dmc$1@newscl01ah.mathworks.com>...
> I need a function which accepts as input a list of real numbers, and a real number X and which returns to the output:
> • The number of how many times the number (X) appear in the table
> • The location where this number appears in the table
> • A table that will have the value 0 in the positions where (X) appears and the value -1 in the remaining positions
> • A table(matrix) where the elements of the original matrix that is larger than the input number (X) will be replaced with the maximum number of the original table
> • A vector which will contain all the unique elements of the input table which are larger than the number(X) we gave to the entrance.

take a look at logical indexing.

tf = T = X
sum(tf)
find(tf)
Y(~tf) = -1
etc.

~ Jos

Subject: matrix function that compare a list of real numbers with a real number

From: someone

Date: 20 Nov, 2012 15:52:07

Message: 4 of 4

"felix " <f_3lix@hotmail.com> wrote in message <k8d4le$dmc$1@newscl01ah.mathworks.com>...
> I need a function which accepts as input a list of real numbers, and a real number X and which returns to the output:
> • The number of how many times the number (X) appear in the table
> • The location where this number appears in the table
> • A table that will have the value 0 in the positions where (X) appears and the value -1 in the remaining positions
> • A table(matrix) where the elements of the original matrix that is larger than the input number (X) will be replaced with the maximum number of the original table
> • A vector which will contain all the unique elements of the input table which are larger than the number(X) we gave to the entrance.

Before trying to compare real numbers,
you should read item 6.1 of the MATLAB FAQ at:

http://matlab.wikia.com/wiki/FAQ

Specifically:

http://matlab.wikia.com/wiki/FAQ#Why_is_0.3_-_0.2_-_0.1_.28or_similar.29_not_equal_to_zero.3F

Tags for 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