フィルターのクリア

Map an array yo another one

10 ビュー (過去 30 日間)
evangeline
evangeline 2018 年 2 月 15 日
編集済み: Stephen23 2018 年 2 月 15 日
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
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?
KL
KL 2018 年 2 月 15 日
B=A ?

サインインしてコメントする。

回答 (2 件)

Andrei Bobrov
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);
  1 件のコメント
Andrei Bobrov
Andrei Bobrov 2018 年 2 月 15 日
fixed!

サインインしてコメントする。


Stephen23
Stephen23 2018 年 2 月 15 日
編集済み: Stephen23 2018 年 2 月 15 日
Use interp1:
>> A = [3,5,6,10];
>> B = [1,2,3,4];
>> interp1(A,B,[5,10])
ans =
2 4

カテゴリ

Help Center および File ExchangeStatistics and Machine Learning Toolbox についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by