Question:

How do I insert extra parameters in a matlab function?

by  |  earlier

0 LIKES UnLike

Im using genetic algorithms and they insert their aproximation, but I need to insert extra variables to the function, how can I do this without declaring them global

This is the function and I need to insert the last part after options are the variables I need to insert as extra

[parmin, fval, exitflag] = ga(@errora,3,[],[],[],[],lb,ub,[],option... fHarm, fHz, fgemCoh, s, s2, i)

 Tags:

   Report

1 ANSWERS


  1. You can edit your functions "header", use cells or if you are using event+listener you can add extra info to your event by creating custom subclass to event and using it to tranfer information from notify->listener (there is more info in 'help events')

    If you don't know what I am talking about, I will recommend modifying function header:

    function varargout = fun(a,b,c)

    to

    function varargout = fun(a,b,c,extra)

    if nargin < 4

    extra = default;

    end

    If I didn't answer your question, please provide more information :)

Question Stats

Latest activity: earlier.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.