How to put a vector in a matrix?

조회 수: 13 (최근 30일)
kyana shayan
kyana shayan 2015년 12월 8일
댓글: Guillaume 2016년 2월 13일
Hi everyone, I want a matrix with one row and 6 columns, which 3 of the first columns are vectors. like this: CoupleElement={ (1,2) , (1,4) , (3,5), 6,7,8 } can anyone help me please? I don't know how to put a vector in an element of a matrix. Thanks for your time

채택된 답변

John BG
John BG 2015년 12월 8일
CE= {(1,2) (1,4) (4,5) 6 7 8} does not work. Start with correct definition of the matrix CE={[1 2] [1 4] [4 5] 6 7 8}
1. read: CE(1) is still a cell, but CE{1} is the initial vector of doubles
2. write: CE(6)={9}
3. append: CE={CE magic(4)} now if you want to read CE(1) is the previous initial cell and CE(2) is magic(4)
back to your initial matrix:
CE={[1 2] [1 4] [4 5] 6 7 8}
kill 2nd row CE(2)=[]
before taking cells head on it really helps to go through the MATLAB help search for 'Add cells to cell array' and carry on reading the related links
crack on
John
  댓글 수: 3
John BG
John BG 2016년 2월 13일
Prego Guillaume, often terms defined in general language dictionaries become outdated, especially in science. The description 'rectangular' you find in English dictionaries is no more the general description of mathematical matrices and arrays, but a specific case.
Just think of for instance of:
A triangular matrix, still a matrix, isn't it?
a 'step' in spheric coordinates (a ball)
a 'rectangle' on a spheric plane, do you still call it a rectangle?
a microwave guide, some are rectangular some are cylindrical
the vertices around a dodecahedron ..
Let's do our best to supply answers, not to open encyclical debates, shall we?
John
Guillaume
Guillaume 2016년 2월 13일
Huh, what's this about? (and why is it popping up two months later?)
The mathematical and scientific languages are extremely accurate languages where each word have a well defined meaning. If you start swapping the meaning of terms, people are going to misunderstand you and you're just going to waste time.
Cell arrays and matrices are very different entities in matlab, from the way they are stored in memory, through the way in which you access the elements, to the set of functions you can use on them.
We often get new users of matlab coming here and asking questions where they use the wrong terms in their question, leading to wasted posts before we figure out what they really mean. The answer to 'I want to sum the rows of my matrix m' is very different if m is really a matrix (answer: use sum(m)) or actually a cell array (answer: in general, you can't).

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by