How can I create a matrix with matrix elements of different datatypes?
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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,
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/801324/image.png)
Please let me know how to create this matix. Thanks in advance!
0 Commenti
Risposte (1)
Dave B
il 16 Nov 2021
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 Commenti
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!