how to fill matrix without using for loop?
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Carlos Oliveira
le 11 Nov 2013
Réponse apportée : Carlos Oliveira
le 11 Nov 2013
a=zeros(24,4); b=ones(24,1);
Why does not this work?
a(:,1:end)=b(:)
Subscripted assignment dimension mismatch.
Does anyone know where I am going wrong? bold
0 commentaires
Réponse acceptée
Plus de réponses (2)
Wayne King
le 11 Nov 2013
Modifié(e) : Wayne King
le 11 Nov 2013
because b isn't the right size. b is 24x1 but you are trying to fill all 4 columns of a
How about just
a = ones(24,4);
or if you really want to "fill" starting with zeros.
a = zeros(24,4);
b = ones(24,1);
b = repmat(b,1,4);
a = b;
0 commentaires
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements 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!