How to convert the augmented matrix A into four column vectors respectively
1 次查看(过去 30 天)
显示 更早的评论
Hello i want asking about how i want to convert matrix into 4 column vector ?
here my homework question
- convert the augmented matrix A into four column vectors respectively
should i put like this A2 = reshape(A.',4,[]) ?
My example matrix is
- for Matrix A
M = [1 2 4; 0 6 1; 1 0 3]
C=[1 1 1]'
A = [M C],
2 个评论
回答(1 个)
Pratik Pawar
2022-5-16
编辑:Pratik Pawar
2022-5-16
If you want to access a particular column, then you can simply assign them to variables as shown in the code below
>> A = [1 2 3 4; 5 6 7 8; 9 10 11 12]
>> C1 = A(:, 1)
>> C2 = A(:, 2)
If you want to access multiple columns or the matrix size is unknown, then you can separate columns using num2cell
>> A = [1 2 3 4; 5 6 7 8; 9 10 11 12]
>> C = num2cell(A, 1)
>> C{1}
>> C{2}
>> C{3}
>> C{4}
OR
[m n] = size(A);
for i = 1:n
C{i}
end
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!