python - What is the equivalent of MATLAB's repmat in NumPy

python - What is the equivalent of MATLAB's repmat in NumPy

I would like to execute the equivalent of the following MATLAB code using NumPy: repmat([1; 1],[1 1 1]). How would I accomplish this?…


arrays - Element-wise array replication in Matlab

Let's say I have a one-dimensional array: a=[1, 2, 3]; Is there a built-in Matlab function that takes an array and an integer n and replicates each element of the array n times? For example calling…


Octave/Matlab: Extend a vector making it repeat itself?

Is there a way to extend a vector by making it repeat itself?>v=[1 2];>v10=v x 5; %x represents some function. Something like "1 2" x 5 in perl Then v10 would be:>v10 1 2 1 2 1 2 1 2 1 2…


Matlab equivalent of Numpy broadcasting?

I'm trying to find some way to substract a size 3 vector from each column of a 3*(a big number) matrix in Matlab. Of course I could use a loop, but I'm trying to find some more efficient solution, a…


arrays - How do I initialise all entries of a matrix with a specific value?

In Haskell, if I wanted to get a 10 element list which only contained the number 5, I could do something like this: take 10 $ repeat 5 Output:[5,5,5,5,5,5,5,5,5,5] Is there anything like this in Ma…


How can I get an array of alternating values in python?

Simple question here: I'm trying to get an array that alternates values(1,-1, 1,-1.....) for a given length. np.repeat just gives me(1, 1, 1, 1,-1,-1,-1,-1). Thoughts?…


Is there an equivalent to the MATLAB function bsxfun in python?

I'm trying to port some of my code from matlab to python, and some of it uses the bsxfun() function for virtual replication followed by multiplication or division(I also use it for logical operation…


MATLAB: duplicating vector 'n' times

This question already has an answer here: Octave/Matlab: Extend a vector making it repeat itself? 2 answers I have a vector, e.g. vector=[1 2 3] I wo…



arrays - In Matlab, when is it optimal to use bsxfun?

My Question: I've noticed that a lot of good answers to Matlab questions on SO frequently use the function bsxfun. Why? Motivation: In the Matlab documentation for bsxfun, the following example is pro…


A similar function to R's rep in Matlab

This question already has an answer here: Element-wise array replication in Matlab 7 answers I am looking for a function that behaves similarly to the rep…




matlab matrix array repeat elements vector python numpy bsxfun repelem