필터 지우기
필터 지우기

Pick numbers from a matrix and create a row vector

조회 수: 1 (최근 30일)
Mitul Dattani
Mitul Dattani 2018년 1월 10일
댓글: Mitul Dattani 2018년 1월 10일
Hi if i have a matrix with input: [1 -2 3 4;3 2 -1 0;5 6 2 1] I want to take the corner elements of this matrix and create a row vector using them called v. I've tried it but keep getting errors, my code is below.
A=input('Give a matrix: '), A;
[m, n]=size(A);
v = [A(1,1), A(1,m), A(n,1), A(m, n)];
[x, y] = size(v);
disp(v)
It seems to work if i only have A(1,1) but not when i start using specific values. The initial matrix is meant to be user inputted.
  댓글 수: 1
Mitul Dattani
Mitul Dattani 2018년 1월 10일
Nevermind figured it out i need to change where i used m and n to end and it works.

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

답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by