How to tell an multi-output anonymous function to vectorize its output components which are constant
1 ビュー (過去 30 日間)
Mohammad Shojaei Arani 2021 年 10 月 16 日
I have an apparently simple but very annoying problem. Consider the function handle
When I want to calculate the expression f([1 2],3) then matlab gives an error message ('mismatch between dimensions'). Of course, I can easily fix this problem by re-defining the above function handle as
However, the problem is that my anonymous function is defined whithin a for-loop where I cannot mannually add x-x to the constants plus that
I do not know beforehand which outputs are constant and which are not. The natural way to fix this problem seems to be to update f like
But, this trick does not work, unfortunately.
It is greatly appreciated if anybody has an idea how to fix this really annoying problem.
Thanks in advance
Babak Shojaei Arani