Variable dimension mismatch problem in a Matlab function block
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Pablo García Auñón
le 7 Jan 2016
Réponse apportée : Pablo García Auñón
le 8 Jan 2016
Hello!
I am getting an error regarding a mismatch between the size of two variables in a Matlab function block:
Dimension 1 is fixed on the left-hand side but varies on the right ([15 x 500] ~= [:15 x :500])
Basically, I have an input variable, A, whose size is variable, and a output variable B, whose size is always [15,500]. Depending on the size of A, the function generates in a different way. For example:
dim_A=size(A);
if dim_A(1)==15
B=A;
else
B=zeros(15,500)
end
The thing is that every time dim_A(1)==15, A's size must be [15,500]. I have also tried to use:
if dim_A(1)==15 && dim_A(2)==500
...
end
but whiout result. The funny thing is that I used exactly the same block in another model and it works there!!
Does anybody know what is going on there??
Thanks a lot! Pablo
0 commentaires
Réponse acceptée
Walter Roberson
le 8 Jan 2016
Try
B = A(1:15,1:500);
even though you know that is the original size, this would provide a clear hint to MATLAB as to the output size.
0 commentaires
Plus de réponses (1)
Voir également
Catégories
En savoir plus sur Simulink Functions dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!