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!