Assign vector to 3d matrix
6 次查看(过去 30 天)
显示 更早的评论
Hi, is there a way to do this?(hope its obvious what i want to do, its initialization for kallman filters used in monte carlo simulations...) Without for cycle?
This give me :
Assignment has fewer non-singleton rhs dimensions than non-singleton subscripts
xhatc = zeros(2,K,N);
xhatc(:,1,1:end) = [1;1];
0 个评论
采纳的回答
更多回答(1 个)
Jan
2018-12-3
编辑:Jan
2018-12-4
If xhatc is defined before:
xhatc(:,1,:) = 1
or maybe:
xhatc(1:2,1,1:end) = 1
It will get clear if you post, if xhatc is defined before, if so in which size and mention the wanted result.
After the editing of the question it is clear, that the first one is efficient and working:
xhatc = zeros(2,K,N);
xhatc(:,1,:) = 1;
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!