i have a function that should work but doesn't
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Omar Almahallawy
am 13 Jun. 2019
Kommentiert: Adam Danz
am 13 Jun. 2019
i'm comparing two arrays and choosing the repeated numbers
and then rearranging the new output in descending order
Y1 = [0.0581 0.0424 0.0315 0.0239 0.0184 0.0143 0.0113 0.0090 0.0073 0.0059]
Z1 = [0.0090 0.0073 0.0059]
X = intersect(Z1, Y1)
Ratio = reshape(sort(X(:), 'descend'), [columns, rows])';
this is the result i get, i don't understand why
Undefined function or variable 'columns'.
Ratio = reshape(sort(X(:), 'descend'), [columns, rows])';
0 Kommentare
Akzeptierte Antwort
Adam Danz
am 13 Jun. 2019
Bearbeitet: Adam Danz
am 13 Jun. 2019
Matlab doesn't know what "columns" means (nor "rows"). My guess is that 'columns' and 'rows' are the number of columns and rows of your reshaped data. Do you know what those values are supposed to be?
In your example data, X is a [1x3] vector. One example would be the following
Ratio = reshape(sort(X(:), 'descend'), [3, 1])';
which is the same as
Ratio = fliplr(sort(X));
2 Kommentare
Adam Danz
am 13 Jun. 2019
Yes, my example using your inputs does not produce an error but make sure this is what your code is supposed to be doing. Just because there isn't an error doesn't mean the code is correct. Many people have learned that the hard way.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!