Conversion of an Matrix
Show older comments
I have an array : A = [0 3 5 7 8 9 1 3 4 0]. I want to convert it into 1x3 matrices such as [0 3 5], [3 5 7], [5 7 8]...[3 4 0] and so on.
My code is:
clc
A = [0 3 5 7 8 9 1 3 4 0];
B = zeros(1, 3);
r=1;
c=3;
for i = r:c
for k = 1:3
B(k) = A(i)
r=r+1;
c=c+1;
end
end
But it doesn't seem to be working correct. Can somebody help?
Accepted Answer
More Answers (0)
Categories
Find more on Matrix Indexing 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!