Skip to content

Instantly share code, notes, and snippets.

View bbrrck's full-sized avatar

Tibor Stanko bbrrck

View GitHub Profile
@bbrrck
bbrrck / replace_indices.m
Last active May 7, 2018 10:03
Matlab: replace indices in a matrix
%% 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);