how to store new matrix on the old one
Show older comments
I have a array Z(4,4) such as
[1:4;
5:8;
9:12;
13:16].
I would like to change the order of the matrix and store in a same name as Z with new version;this for the first iteration. for the second iteration; I want to use the previous version and do the same changes on the order to get new one.keep doing this for m iteration.
for k=1:m,
D=[];
for j=1:4,
for i=1:4,
C=A*[i;j];
[x]=mod(C(1),4)+1
[y]=mod(C(2),4)+1
D=[D;Z(x,y)];
end;
E=[E,D];D=[];
end;
NewZ(k)=E;E=[];
Z=NewZ;
end;
always I get this error: Subscripted assignment dimension mismatch.
Please I need a help.
6 Comments
the cyclist
on 25 May 2014
What is A? Can you post some self-contained code that we can just try to run, which will exhibit the error?
sundus
on 25 May 2014
dpb
on 25 May 2014
and m and E?
Show the error message in its entirety in the context of the run w/ the above definitions.
sundus
on 25 May 2014
dpb
on 25 May 2014
Don't know if it will produce what you expect or not, but the error comes from
NewZ(k)=E;
where you're trying to store an array in an element. Perhaps what you're looking for is
NewZ=[NewZ;E]; E=[];
to concatenate the E onto NewZ
sundus
on 25 May 2014
Accepted Answer
More Answers (0)
Categories
Find more on Linear Algebra 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!