Assign vector to 3d matrix

12 vues (au cours des 30 derniers jours)
Jakub Matousek
Jakub Matousek le 3 Déc 2018
Réponse apportée : Matt J le 4 Déc 2018
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];

Réponse acceptée

Matt J
Matt J le 4 Déc 2018
xhatc(:,1,:) = repmat([1;1],1,1,N);

Plus de réponses (1)

Jan
Jan le 3 Déc 2018
Modifié(e) : Jan le 4 Déc 2018
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;
  1 commentaire
Jakub Matousek
Jakub Matousek le 3 Déc 2018
Edited

Connectez-vous pour commenter.

Catégories

En savoir plus sur Monte-Carlo dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by