Filter löschen
Filter löschen

Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

How can i make my unique search function work correctly?

1 Ansicht (letzte 30 Tage)
Barnabas
Barnabas am 19 Jun. 2013
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
I have a unique sort function to search an array, and find at what points the data values change. Unfortunately it only works for data values that are increasing, and intermittently. It does not count all of the values.
[~,T] = unique(Torque,'first'); [T] = sort(T,'ascend');
Example Array [0 0 1 2 3 2 1 0 0 0 10 20 30 20 10 0 0 0 ]
I would like it to give me the line # everytime the value in the area changes from the previous one, and ideally set it for what increment to look for. Thanks, any help is appreciated.
  2 Kommentare
Jan
Jan am 19 Jun. 2013
Bearbeitet: Jan am 19 Jun. 2013
I do not understand the question. Could you provide the wanted result for your example array?
Roger Stafford
Roger Stafford am 20 Jun. 2013
Like Jan and Cyclist I do not understand your question, Barnabas. Your statement "give me the line # everytime the value in the area changes from the previous one" seems totally unrelated to the code you exhibit. Do "line #"and "value in the area" apply to the 'Torque' array or to the 'T' array of indices? If you are talking about the original 'Torque' array and you want to see the points in it where a change occurs, you should be applying the 'diff' function to it, as Cyclist said, something like:
diff(Torque) ~= 0
which would give you a list of trues and falses indicating changes or lack thereof. If you do a 'find' function on this list it will give you the addresses of where all the changes are occurring.
See if you can't come up with a much more detailed explanation of what you are seeking.

Antworten (1)

the cyclist
the cyclist am 20 Jun. 2013
I am not sure I fully understand your question, and agree with Jan's suggestion in his comment.
That being said, I think you might find the diff() command might do exactly what you want.

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by