I'm trying to convert the following python code to Matlab, However, I cannot find the equivalent of repeat. I tried "repmat" but didn't get the same results. k.size is 64 and LL is a 10 * 10 matrix.
Id = (2 * LL).repeat(K.size).reshape(-1, 8, 8)
Also, How can I convert the (2 * LL).repeat(K.size) to the shape of (-1,8,8) in matlab.
You could do the following.
k_size = 64; % specify K.size
m = 8; n = 8; % specify dimensions of each Id slice
LL = reshape(1:100,[],10); % specify matrix LL
M = 2*LL.'; %
Id = reshape(repmat(M(:),k_size,1),[],m,n);
If you want an equivalent to repeat, you can do the following.
function v = repeat(M,k)
Mt = M.';
A = repmat(Mt(:),k).';
v = A(:);
end
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.