How can I extract entries from a matrix and a vector into a new vector in a specific way?
조회 수: 2 (최근 30일)
이전 댓글 표시
Hello, I want to extract the entries of a matrix and a vector into a new vector, like this:
M =
0.6000 0.8000
-0.8000 0.6000
t =
0.4000
0.8000
into this vector: v =
0.6000
0.8000
-0.8000
0.6000
0.4000
0.8000
How can I do it? and I would like to know how to do it the other way, like this: if v is given and I want to construct M and t from that v.
Thank you for your help!!
댓글 수: 0
채택된 답변
추가 답변 (1개)
mounika
2017년 11월 25일
M = [0.6,0.8;-0.8,0.6]
t = [0.4;0.8]
M = reshape(M,4,1)
v = vertcat(M,t)
Otherway:
M = v(1:4,:);
M = reshape(M,2,2);
t = v(5:6,;);
댓글 수: 2
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!