Unable to perform assignment because the size of the left side is 7-by-1 and the size of the right side is 7-by-7
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Sim
le 11 Juil 2020
Commenté : Walter Roberson
le 11 Juil 2020
Hi, I would like to pass some extra arguments to my ODE as follows:
[T,H] = ode23t(@(t,h) MYODE(t,h,G,N,e,n,z,initialnode,w,Qcell,lambda), tspan, h0, opts);
[~,Qcell] = cellfun(@(t,h) MYODE(t,h,G,N,e,n,z,initialnode,w,Qcell,lambda), num2cell(T), num2cell(H,2), 'uni',0);
but I get this error:
Unable to perform assignment because the size of the left side is 7-by-1 and the size of the right side is 7-by-7.
Any idea on how to fix it?
0 commentaires
Réponse acceptée
Walter Roberson
le 11 Juil 2020
The boundary conditions, h, will always be passed to the function as a column vector even if you initialize as a row vector. Your extra arguments have at least one row vector that you are combining elementwise with h thinking that h is a row vector. But because it is a column vector you are getting implicit expansion, as if you had used bsxfun.
Review your code and ensure that you have the right orientation for all your inputs taking into consideration that h will be received as a column vector.
2 commentaires
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!