Skip to content

Instantly share code, notes, and snippets.

Avatar

Tibor Stanko bbrrck

View GitHub Profile
@bbrrck
bbrrck / replace_indices.m
Last active May 7, 2018
Matlab: replace indices in a matrix
View replace_indices.m
%% test data
% random seed
rng(1234567890);
% vector of original indices
A = (101:110)';
% random vector of new indices
% same length as A, can have duplicates
B = randi([1 10],length(A),1);
% random matrix with indices from A
MA = randi(A([1 end]),10,3);