Map an array yo another one
10 次查看(过去 30 天)
显示 更早的评论
I have an array like: A=[3,5,6,10] and I need to map it to another one like: B=[1,2,3,4] so instead of returning A, I can return B. how can I do this?
2 个评论
Guillaume
2018-2-15
The question is really not clear. What does map mean? How do you go from [3 5 6 10] to [1 2 3 4]? What is the rule?
回答(2 个)
Andrei Bobrov
2018-2-15
编辑:Andrei Bobrov
2018-2-15
A=[3,5,6,10];
B=[1,2,3,4];
C = randsrc(8,5,B);
ii = discretize(C,B);
out = A(ii);
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Statistics and Machine Learning Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!