How to store matrix whose dimension is changing in each iteration ?
1 view (last 30 days)
Show older comments
hello all
How to store matrix whose dimension is changing in each iteration?
can anyone expalin with example?
0 Comments
Answers (2)
KALYAN ACHARJYA
on 24 May 2019
Edited: KALYAN ACHARJYA
on 24 May 2019
Cell array
result=cell(1,iter);
for i=1:iter
%say matrix1 have changes the dimention in each iteration
% do operation, say matrix1 is the result in this iteraion.
result{i}=matrix1
end
Exampele:
>> A=rand(2,4)
A =
0.9324 0.2304 0.8681 0.9226
0.2963 0.1660 0.2219 0.9020
>> B=magic(3)
B =
8 1 6
3 5 7
4 9 2
>> result={A,B}
result =
1×2 cell array
{2×4 double} {3×3 double}
>>
3 Comments
KALYAN ACHARJYA
on 28 May 2019
Edited: KALYAN ACHARJYA
on 28 May 2019
Where is the issue, can you share?
As per your question>>
How to store matrix whose dimension is changing in each iteration ?
Best way Celll Array (Alreadt shown the example too)
>> A=rand(2,4)
A =
0.9324 0.2304 0.8681 0.9226
0.2963 0.1660 0.2219 0.9020
>> B=magic(3)
B =
8 1 6
3 5 7
4 9 2
>> result={A,B}
result =
1×2 cell array
{2×4 double} {3×3 double}
>>
Here we have saved the two matrix having sizes 2x4 and 3x3 in result cell array.
See Also
Categories
Find more on Matrices and Arrays 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!