|
Prev: Audio - Auto level Control AGC
Next: fminsearch problem
From: MZ AM on 11 May 2010 11:49 Hi, I am using a built-in function of MATLAB, which is fmincon. I have hard time providing correct data for one of the input variables. This variable can take a vector containing only double-type data. But the data I am trying to pass on it is something like: [3 2 null null 5 null 10] where null is an empty ( [ ] ) element. The reason that I want null entity is that the above vector applies a constraint on the program, but sometimes under some conditions I do not need any constraints for the calculations and that's why I use null. The above form of data, however, is not an appropriate double-type data although I can simply create it as a cell array, but as I mentioned cell arrays are not acceptable only double-type data. Also I tried to convert the above data (created by cell array definition) to a double type data by str2double but after conversion I get: [3 2 Nan NaN 5 NaN 10] which of course makes sense. Can anyone give me some hints how I can create the above data in the form of double-type data? Thanks, Manuel
From: Walter Roberson on 11 May 2010 12:14 MZ AM wrote: > I am using a built-in function of MATLAB, which is fmincon. I have hard > time providing correct data for one of the input variables. This > variable can take a vector containing only double-type data. But the > data I am trying to pass on it is something like: > > [3 2 null null 5 null 10] > > where null is an empty ( [ ] ) element. > Can anyone give me some hints how I can create the above data in the > form of double-type data? You cannot, not without using NaN or inf instead of null. I do not know enough about fmincon to know the standard mechanism for indicating you want a particular parameter to be unconstrained. I would think that in practice, supplying realmax as the constraint value would have the desired effect -- if the value that would be found through the search exceeds realmax, then it isn't representable in standard double precision.
From: Steven Lord on 11 May 2010 14:02 "Walter Roberson" <roberson(a)hushmail.com> wrote in message news:CnfGn.1198$%u7.425(a)newsfe14.iad... > MZ AM wrote: > >> I am using a built-in function of MATLAB, which is fmincon. I have hard >> time providing correct data for one of the input variables. This variable >> can take a vector containing only double-type data. But the data I am >> trying to pass on it is something like: >> >> [3 2 null null 5 null 10] >> >> where null is an empty ( [ ] ) element. > >> Can anyone give me some hints how I can create the above data in the form >> of double-type data? > > You cannot, not without using NaN or inf instead of null. > > I do not know enough about fmincon to know the standard mechanism for > indicating you want a particular parameter to be unconstrained. I would > think that in practice, supplying realmax as the constraint value would > have the desired effect -- if the value that would be found through the > search exceeds realmax, then it isn't representable in standard double > precision. http://www.mathworks.com/access/helpdesk/help/toolbox/optim/ug/fmincon.html?BB=1 " If x(i) is unbounded below, set lb(i) = -Inf, and if x(i) is unbounded above, set ub(i) = Inf." -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
From: MZ AM on 13 May 2010 12:25 Thank you Walter for your reply. Basically I do not need any constraint under some numerical circumstances that's why I use null. If I understood you correctly, the use of realmax that you explained may simulate something like infinity for my constraint, which is not correct in my case. MZ
From: MZ AM on 13 May 2010 12:30
Thanks Steve for your reply. Actually what I am looking for is not the "lb" or "ub" (in fact I specify some other values that are independent of the above-mentioned constraints). The constraints in my case are similar to g(x) in description of fmincon in MATLAB manual. MZ |