Prev: Enumeration
Next: Radon Transform
From: mat001 on 9 Feb 2010 09:03 Parker <xenoszh(a)gmail.com> wrote in message <7a37f55f-5f5c-4d30-988f-978c36e0d904(a)n33g2000yqb.googlegroups.com>... > On 2月9日, 下午12时10分, "mat001 " <priya.biom...(a)gmail.com> wrote: > > Parker <xeno...(a)gmail.com> wrote in message <e54d1809-c0c2-4d20-be5c-9a432d501...(a)3g2000yqn.googlegroups.com>... > > > On 2月9日, 上午11时10分, "mat001 " <priya.biom...(a)gmail.com> wrote: > > > > function Aijk = Prob(i, j, k, parameter, varargin) > > > > if ((i == eq.n1) & (j == eq.n1) & (k == eq.n1)) > > > > switch varargin{3} % what is means ? > > > > case 'x' > > > > Aijk = > > > > case 'y' > > > > Aijk = > > > > case 'z' > > > > Aijk = > > > > otherwise > > > > error('unknown case'); > > > > end > > > > else > > > > error(); > > > > end > > > > > > return > > > > > > Parker little more explain plz. > > > > > according to the 'function Aijk = Prob(i, j, k, parameter, varargin) > > > ' , > > > varargin should be a cell array contain several elements > > > the switch statement will check the third element of varargin and > > > assign the output or raise an error based on the Value of it. > > > > Thanks for explanation....... > > so to call this function > > > > if I say > > > > test1 = Prob(i, j, k, parameter, [],[],'x') > > > > so it will give case 'x' > > > > or if > > > > test2 = Prob(i, j, k, parameter, [],[],'y') > > > > so it will give case 'y' > > and similarly for z > > varargin is a cell array,try use { } to declare it as a cell array > like: > > test2 = Prob(i, j, k, parameter, {[],[],'y'}) > ========================================= > it should be OK > here is my test > > function out = tryCell(i,j,k,varargin) > out = length(varargin); > switch varargin{3} > case 'x' > out = 'x'; > case 'y' > out = 'y'; > case 'z' > out = 'z'; > otherwise > error('error'); > end > end > > test as > >> tryCell(1,2,3,1,2,'x') > ans = > x > >> tryCell(1,2,3,1,2,'y') > ans = > y > >> tryCell(1,2,3,1,2,'z') > ans = > z Thanks once again. here is tryCell(1,2,3,1,2,'x') 1 23 are i j k what is 1 2 in 1 2 'x'
From: Parker on 9 Feb 2010 10:26 On 2æ9æ¥, ä¸å2æ¶03å, "mat001 " <priya.biom...(a)gmail.com> wrote: > Parker <xeno...(a)gmail.com> wrote in message <7a37f55f-5f5c-4d30-988f-978c36e0d...(a)n33g2000yqb.googlegroups.com>... > > On 2月9日, 下午12时10分, "mat001 " <priya.biom...(a)gmail.com> wrote: > > > Parker <xeno...(a)gmail.com> wrote in message <e54d1809-c0c2-4d20-be5c-9a432d501...(a)3g2000yqn.googlegroups.com>... > > > > On 2月9日, 上午11时10分, "mat001 " <priya.biom...(a)gmail.com> wrote: > > > > > function Aijk = Prob(i, j, k, parameter, varargin) > > > > > if ((i == eq.n1) & (j == eq.n1) & (k == eq.n1)) > > > > >  switch varargin{3} % what is means ? > > > > >   case 'x' > > > > >   Aijk = > > > > >   case 'y' > > > > >   Aijk = > > > > >   case 'z' > > > > >   Aijk = > > > > >   otherwise > > > > >   error('unknown case'); > > > > >  end > > > > > else > > > > >  error(); > > > > > end > > > > > > return > > > > > > Parker little more explain plz. > > > > > according to the 'function Aijk = Prob(i, j, k, parameter, varargin) > > > > ' , > > > > varargin should be a cell array contain several elements > > > > the switch statement will check the third element of varargin and > > > > assign the output or raise an error based on the Value of it. > > > > Thanks for explanation....... > > > so to call this function > > > > if I say > > > > test1 = Prob(i, j, k, parameter, [],[],'x') > > > > so it will give case 'x' > > > > or if > > > > test2 =  Prob(i, j, k, parameter, [],[],'y') > > > > so it will give case 'y' > > > and similarly for z > > > varargin is a cell array,try use { }  to declare it as a cell array > > like: > > > test2 =  Prob(i, j, k, parameter, {[],[],'y'}) > > ========================================= > > it should be OK > > here is my test > > > function out = tryCell(i,j,k,varargin) > > out = length(varargin); > > switch varargin{3} > >   case 'x' > >       out = 'x'; > >   case 'y' > >       out = 'y'; > >   case 'z' > >       out = 'z'; > >   otherwise > >       error('error'); > > end > > end > > > test as > > >> tryCell(1,2,3,1,2,'x') > > ans = > > x > > >> tryCell(1,2,3,1,2,'y') > > ans = > > y > > >> tryCell(1,2,3,1,2,'z') > > ans = > > z > > Thanks once again. > > here is tryCell(1,2,3,1,2,'x') > > 1 23 are i j k > > what is 1 2 in 1 2 'x' just a test to show that, first 1,2,3 refer to the i,j,k in tryCell(i,j,k,varargin) then 1,2, 'x' refer to varargin
From: mat001 on 9 Feb 2010 10:50
Thanks |