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

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.

2 Comments

Please stop using this site as a homework solving service. All the things you should have learned from the problem we discussed yesterday
can be applied to this problem now.
sorry about that. can you link me where i can lear basic about matricies or generaly about matlab functions?

Sign in to comment.

Answers (1)

OK. Do you have a question? Why don't you just use unique():
allTheNumbers = unique(X);
and then find out where they occur
mapOfNumber = (X == allTheNumbers(1)); % Find out where the first number occurs.
and so on.
If you have floating point numbers, not numbers of class "int32" or other integer types, be aware of the FAQ: http://matlab.wikia.com/wiki/FAQ#Why_is_0.3_-_0.2_-_0.1_.28or_similar.29_not_equal_to_zero.3F

Asked:

on 19 Nov 2012

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!