필터 지우기
필터 지우기

Reshape a matrix order

조회 수: 2 (최근 30일)
Aswas
Aswas 2016년 5월 16일
편집: Aswas 2016년 5월 16일
Hi,
Vv =
1
2
3
4
5
6
7
8
9
and have transposed onto :
g =
-1 -1 -1 -1 -1 -1 -1
-1 1 3 5 0 0 8
-1 2 4 6 7 0 9
and using
Ans(zi) = reshape([Vv'], [], 1)'; to get reshaped to:
-1 -1 -1 -1 -1 -1 -1
-1 1 2 3 0 0 4
-1 5 6 7 8 0 9
but keep getting error.
  댓글 수: 1
Jan
Jan 2016년 5월 16일
What is your question? Which error messages do you get? Wher do the "-1" in the output come from?

댓글을 달려면 로그인하십시오.

채택된 답변

Jan
Jan 2016년 5월 16일
With some guessing:
GT = G.';
zi = find(GT == 0);
GT(zi) = Vv;
g = GT.';
  댓글 수: 1
Aswas
Aswas 2016년 5월 16일
편집: Aswas 2016년 5월 16일
Thanks Jan, Walter.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2016년 5월 16일
You are reshaping the row vector Vv' to be a row vector and the transposing it to a column vector, ending up back with the same Vv column vector you started from. You then try to store that entire column vector at the location Ans(zi) . If zi is not a column vector of the same length as Vv, that is going to be an error.
You should avoid using a variable named Ans as it could easily be confused with ans
  댓글 수: 1
Jan
Jan 2016년 5월 16일
@Aswas: Please learn hiow you use the "{} Code" button in the forum's interface. Thanks.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by