From: Jean-Philip Dumont on 3 Aug 2010 10:23 Hi, I need to find the value of an input that makes an equation equal to zero. I realized in my data that only making fluctuate one variable is not enough and sometimes fzero is not able to fin a zero. Is there a way to make fluctuate two variables for this optimization function? Here, only H is varying and I would like to find a zero when H and K are varying. Here is my code: for i=1:length(I) for k=1:length(Echeances) names = fieldnames(ResultsAll.(RAnames{k,1}).Trend); for l=1:length(Cnames) for m=1:length(names) for o=1:length(ResultsAll.(RAnames{k,1}).Trend.(names{m,1}))-... Echeances(k,1) St = ResultsAll.(RAnames{k,1}).Trend.(names{m,1})(o,1); r = ResultsAll.(RAnames{k,1}).TBill_Can.(names{m,1})(o,1); rf = ResultsAll.(RAnames{k,1}).TBill_US.(names{m,1})(o,1); Vol = ResultsAll.(RAnames{k,1}).Vol.(names{m,1})(o,1); if I(1,i)==0 K = St*(1-B); elseif I(1,i)==1 K = St*(1+B); end H0 = St; % Starting value of the optimisation H_Ks.(Inames{1,i}).(Dnames{1,k}).(Cnames{1,l}).(names{m,1})... (o,1)=fzero(@CTBzc,H0,Options,K,CoutO(l,1)*N,N,r,rf,Vol,... St,EcheancesFD(k,1)/360,I(1,i)); H_Ks.(Inames{1,i}).(Dnames{1,k}).(Cnames{1,l}).(names{m,1})... (o,2)=K; end end end end end Thank you very much!
From: John D'Errico on 3 Aug 2010 10:44 "Jean-Philip Dumont" <jean-philip.dumont(a)hec.ca> wrote in message <i398o8$k75$1(a)fred.mathworks.com>... > Hi, > > I need to find the value of an input that makes an equation equal to zero. > > I realized in my data that only making fluctuate one variable is not enough and sometimes fzero is not able to fin a zero. > > Is there a way to make fluctuate two variables for this optimization function? No. fzero is a ONE variable solver. To solve problems with TWO variables and TWO equations, you need something designed for more than one variable. Look at the optimization toolbox. help fsolve John
From: Jean-Philip Dumont on 3 Aug 2010 14:32 "John D'Errico" <woodchips(a)rochester.rr.com> wrote in message <i399vk$bsn$1(a)fred.mathworks.com>... > "Jean-Philip Dumont" <jean-philip.dumont(a)hec.ca> wrote in message <i398o8$k75$1(a)fred.mathworks.com>... > > Hi, > > > > I need to find the value of an input that makes an equation equal to zero. > > > > I realized in my data that only making fluctuate one variable is not enough and sometimes fzero is not able to fin a zero. > > > > Is there a way to make fluctuate two variables for this optimization function? > > No. fzero is a ONE variable solver. > > To solve problems with TWO variables and TWO > equations, you need something designed for > more than one variable. Look at the optimization > toolbox. > > help fsolve > > John Thank you John, I appreciate your help! JP
|
Pages: 1 Prev: Load in part of variable from .mat file Next: How to close a figure without critical error |