error with number replication in a cell array
古いコメントを表示
Hi guys, mx is a 100x61 cell array. I want to replicate the numbers of all cells in the cell array with the following formula but i get the following error:
n=61
for f = 1:n
for k=1:length(mx)
myCells{k,f} = [mx{k,f} ((kron([mx{k,f}], ones(4,1))))];
end
end
Error using horzcat Dimensions of matrices being concatenated are not consistent.
I tried many things to correct it but it didnt help. can anyone help.
5 件のコメント
Guillaume
2014 年 11 月 15 日
Of course, you get an error. You're never going to be able to concatenate a matrix with its kronecker tensor product with another matrix since by definition the size of the product is much larger than the original matrix.
This has nothing to do with cell array. What exactly are you trying to do?
AA
2014 年 11 月 15 日
The kron bit is fine. But in your original example you also concatenate horizontally the result with the original matrix. This is only going to work if your other matrix in kron is only one row.
Did you mean to concatenate the matrices vertically instead?
AA
2014 年 11 月 15 日
Guillaume
2014 年 11 月 15 日
You can't concatenate horizontally matrices with a different numbers rows, no matter what.
Since your kron creates a matrix with the same numbers of columns, you can do the concatenation vertically as in my answer.
Once again, this has nothing to do with cell arrays and the size of the cell array is irrelevant. It's simply to do with matrix concatenation.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!