creation of toeplitz matrix
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Good morinig,
i have a cell matrix ( 6 x 1 ) where inside each cell i have a vector of two values. I would like to get a toeplitz matrix and I tried to use the command toeplitz(c,r) but I got the following error 'Inputs must be numeric'. In fact inside each cell I don't have a single value but a vector of two values.
What can i do? thanks
0 comentarios
Respuestas (1)
Star Strider
el 15 de Dic. de 2021
It would help to see the code, since I have no idea what ‘r’ is.
That aside, try something like this —
cell_matrix = {rand(1,2); rand(1,2); rand(1,2)}
r = rand(1,2)
tm = toeplitz([cell_matrix{:}], r)
This indexing convention extracts the data in the comma-separated list of the cell array and concatenates it, creating a numeric vector. I have no idea if that numeric vector is the desired one. Another option is the cell2mat function.
.
2 comentarios
Star Strider
el 15 de Dic. de 2021
It appears to be a ‘cell-of-cells’, so —
cell_matrix = { {[0.9503 0.5174]}
{[0.2850 0.6280]}
{[0.4221 0.3325]} }
M = cellfun(@cell2mat, cell_matrix, 'Unif',0)
M = cell2mat(M)
c = M(:,1)
r = M(1,:)
Tm = toeplitz(c, r)
That would appear to be the desired result.
.
Ver también
Categorías
Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!