creation of toeplitz matrix
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Star Strider
2021-12-15
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 个评论
Star Strider
2021-12-15
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.
.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!