How do i create variables that store arrays
5 views (last 30 days)
Show older comments
Suppose I have some matrices, A,B,C to Z.
A = [ 1 2 3 4; 1 2 3 4]
B = [ 1 2 1 2; 3 2 1 2]
....
Z = [1 3 1 3; 2 3 2 3]
Like vectors, how can I create variables that store these arrays in order?
ex) v=[ 1;2;3;4;5;6;1;2;3;4;5;] v(2)=2
What I want is
Array (2) = B = [1212; 3212] appears.
0 Comments
Accepted Answer
Voss
on 17 May 2022
You can use a cell array:
Array = { ...
[ 1 2 3 4; 1 2 3 4] ...
[ 1 2 1 2; 3 2 1 2] ...
[ 1 3 1 3; 2 3 2 3] ...
};
Array{1}
Array{2}
Array{3}
v = {[1;2;3;4;5;6;1;2;3;4;5;] 2};
v{1}
v{2}
Array and v are each cell arrays.
2 Comments
Voss
on 17 May 2022
You can use curly braces { } to construct a cell array. For example:
t = 0:10;
A = { ...
[zeros(size(t)); ones(size(t))] ...
t.^2+2*t-4 ...
}
A{1}
A{2}
More Answers (0)
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!