Program to perform a reshape of an array
Show older comments
Greetings of the day
I have W and would like to obtain P as indicated below.
W=[1 1 1 1 0 1 1 1;0 1 1 1 1 1 0 1;1 0 1 0 1 1 0 1;1 1 0 0 1 1 0 1;1 1 0 0 1 1 0 0]
for k=1:5
M=reshape(W(k,:),4,2)
end
P=bi2de(M)
%Modify the above program and obtain a matrix that contains all values as
%follows:
P=[2 3 3 3;1 3 2 3;3 1 2 1;3 3 0 1;3 3 0 0];
Thank you so much.
Accepted Answer
More Answers (1)
darova
on 26 May 2021
Use reshape without for loop
M = reshape(W',4,[]);
1 Comment
Ronald Niwamanya
on 26 May 2021
Categories
Find more on Resizing and Reshaping Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!