フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

how to display the values of an array within the specific bin ranges (index positions)?

1 回表示 (過去 30 日間)
pavan sunder
pavan sunder 2016 年 11 月 2 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
i have [1xm] array.How to display the values of an array within the specific bin ranges (index positions)?
ex:
x=[1 2 4 5 7 5 7 8 3 12 45 32 54 67]
idx1=[2 7 12]
idx2=[5 10 14]
output is again [1xm] matrix
y=[0 2 4 5 7 0 7 8 3 12 0 32 54 67]

回答 (1 件)

Guillaume
Guillaume 2016 年 11 月 2 日
One possible solution:
y = zeros(size(x));
indices = cell2mat(arrayfun(@(istart, iend) istart:iend, idx1, idx2, 'UniformOutput', false));
y(indices) = x(indices)

この質問は閉じられています。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by