How to define a function whose number of outputs depend on an input parameter value?
Show older comments
Say for M = 4, I have a code below.
function [c,ceq] = Constraint(M)
c = [];
for i=1:M
ceq_{i} = i;
end
ceq = [ceq_{1} ceq_{2} ceq_{3} ceq_{4}];
end
My question is for bigger values of M, how do I define the last ceq so that I don't have to write each ceq_{i}'s individually?
Accepted Answer
More Answers (0)
Categories
Find more on Direct Search in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!