Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Matlabでは、インデックス(a = [2 7]など)と値(b = [123 642]など)のリストを指定しました。指定されたインデックスの値を持つベクトル(c)を返す関数fが必要です。間のゼロ。
したがって:c = [0 123 0 0 0 0 642]
このタスクを実行するにはどうすればよいですか?
よろしく、
Vcent
線形インデックスを使用できます。
c = zeros(1,max(a)); %Not required if c does not exist, but I would recommend it c(a) = b