How to write such a matrix

조회 수: 18 (최근 30일)
johnny
johnny 2011년 4월 13일
Hi,
i need help. I want to create matrix which look like this:
1 B B B B
A C D D D
A C D D D
A D D D D
A D D D D
A D D D D
A D D D D
Elements: A = 0:1:6, B = 0:1:4, C = A*B, D = 12.
Thank you very much.
  댓글 수: 2
Andrei Bobrov
Andrei Bobrov 2011년 4월 13일
can so? (sorry for my english)
1 B1 B2 B3 B4
A1 C D D D
A2 C D D D
A3 D D D D
A4 D D D D
A5 D D D D
A6 D D D D
Elements: A = 1:6, B = 1:4, C(i,j) = A(i)*B(j), D = 12.
Jan
Jan 2011년 4월 13일
Please specify the dimensions of C." A=0:6, B = 0:4, C = A*B" creates an error.

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

답변 (2개)

Paulo Silva
Paulo Silva 2011년 4월 13일
m=ones(7,5);
A=2;B=3;C=A*B;D=12;
m(1,2:end)=B;
m(2:end,1)=A;
m(2:end,2:end)=D;
m(2:3,2)=C;
m

Sean de Wolski
Sean de Wolski 2011년 4월 13일
What's wrong with the method that you have above; i.e. defining it explicitly? It'll be the fastest and easiest to read.

카테고리

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