How to put a vector in a matrix?

14 visualizaciones (últimos 30 días)
kyana shayan
kyana shayan el 8 de Dic. de 2015
Comentada: Guillaume el 13 de Feb. de 2016
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

Respuesta aceptada

John BG
John BG el 8 de Dic. de 2015
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 comentarios
John BG
John BG el 13 de Feb. de 2016
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 el 13 de Feb. de 2016
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).

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by