How to generate reverse function
7 次查看(过去 30 天)
显示 更早的评论
Write a matlab function called myReverseFunction. This function should accept
one vector as input parameter and return one vector as output parameter. This function should reverse the
location of elements from left to right. You should define a vector and call myReverseFunction.
Example: Example:
My vector is 1,3,5,7,6,11,22
Function returns 22,11,6,7,5,3,1
采纳的回答
Walter Roberson
2021-2-8
SomeData = randi(9, 1, 10)
myReversFunction(SomeData)
function OtherData = myReversFunction(OtherData)
Flurp = (1:length(OtherData)).' == (length(OtherData):-1:1);
[~, Gurp] = max(Flurp,[],1);
OtherData = OtherData(Gurp);
end
0 个评论
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!