Info
Cette question est clôturée. Rouvrir pour modifier ou répondre.
In an assignment A(I) = B, the number of elements in B and I must be the same
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
whenever i execute following code it gives an error "In an assignment A(I) = B, the number of elements in B and I must be the same.". How can i overcome the problem?
for i = 1:3
mr_Ch(i) = (transpose(lab1_EEG(i,:))) - mean(transpose(lab1_EEG(i,1)));
end
0 commentaires
Réponses (1)
Jan
le 11 Fév 2016
Modifié(e) : Jan
le 11 Fév 2016
This is a column vector:
temp1 = transpose(lab1_EEG(i,:)))
This is a scalar:
temp2 = mean(transpose(lab1_EEG(i,1)))
In consequence this is a column vector also:
temp3 = temp1 - temp2
Now you try to assign this vector to a scalar variable:
mr_Ch(i) = temp3
This must fail. What do you want to store in mr_Chi? We cannot guess, what you want to achieve. But perhaps this helps - without a loop:
mr_Chi = bsxfun(@minus, lab1_EEG, mean(lab1_EEG, 1)).';
1 commentaire
Cette question est clôturée.
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!