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

2 次查看(过去 30 天)
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 个评论
Matt J
Matt J 2012-11-19
编辑:Matt J 2012-11-19
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.
felix
felix 2012-11-20
sorry about that. can you link me where i can lear basic about matricies or generaly about matlab functions?

请先登录,再进行评论。

回答(1 个)

Image Analyst
Image Analyst 2012-11-19
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

类别

Help CenterFile Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by