How can I create a matrix with matrix elements of different datatypes?
조회 수: 11 (최근 30일)
이전 댓글 표시
I want to make a nx2 matrix in which the first column consists of integers but the second column consists of a structure. Something like this,
Please let me know how to create this matix. Thanks in advance!
댓글 수: 0
답변 (1개)
Dave B
2021년 11월 16일
You can use a cell array to mix datatypes:
n=5;
mat = cell(n,2);
for i = 1:n
mat{i,1} = i;
mat{i,2} = -i:i;
end
mat
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!