Effacer les filtres
Effacer les filtres

Error using * inner matrix dimensions must agree

1 vue (au cours des 30 derniers jours)
Subham Burnwal
Subham Burnwal le 14 Avr 2015
Modifié(e) : Star Strider le 14 Avr 2015
I have written a function in which one line is B = A*i; where A is a matrix and i is a scalar quantity.
i am calling this function many times around 4000 and the problem is for some time this statement is executing properly and after some time this error is showing at this line i do not know why. One more thing is that the function is executing different number of times when i am running it again and again.
Thank you.

Réponses (2)

James Tursa
James Tursa le 14 Avr 2015
Most likely i is not a scalar, hence the error. Try stopping on the error and then examining the dimensions to see what is going on.
dbstop if error
% then run your code
  2 commentaires
Subham Burnwal
Subham Burnwal le 14 Avr 2015
Now In the workspace it is showing i as an empty matrix at the break point. How can i remove this error now.? i want to use i as a scalar. Thank You.
James Tursa
James Tursa le 14 Avr 2015
Modifié(e) : James Tursa le 14 Avr 2015
Look upstream in your code. Where do you define i? You must be defining it somewhere otherwise i would default to the inbuilt imaginary unit.

Connectez-vous pour commenter.


Star Strider
Star Strider le 14 Avr 2015
Modifié(e) : Star Strider le 14 Avr 2015
If ‘i’ is always a scalar, it should’t be throwing that error. Add this line before the ‘B’ assignment:
if sum(size(i)) ~= 2
fprintf(['\n\ti = ' repmat('%f ', 1, length(i)) '\n'], i)
end
B = A*i;
That will tell you if ‘i’ has somehow become a vector.

Catégories

En savoir plus sur Logical 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