Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.


Math Forum
»
Discussions
»
Software
»
comp.softsys.matlab
Notice: We are no longer accepting new posts, but the forums will continue to be readable.
Topic:
Handle function implicitly accounting for independent variables
Replies:
2
Last Post:
Jan 7, 2013 2:08 PM




Re: Handle function implicitly accounting for independent variables
Posted:
Jan 7, 2013 9:55 AM


"Francesco Perrone" <francesco86perrone@yahoo.it> wrote in message news:kce363$opt$1@newscl01ah.mathworks.com... > I have that
*snip*
> E = @(k) (1.453*k.^4)./((1 + k.^2).^(17/6));
*snip*
> Afterwards, I compute F_33 as > > for i = 1:numel(k1) count = count + 1; phi_33 = @(k2,k3) > (1.453./(4.*pi)).*(((k1(i)^2+k2.^2+(k3 + > beta(i).*k1(i)).^2).^2)./((k1(i)^2+k2.^2+k3.^2).^2)).*((k1(i)^2+k2.^2)./((1+k1(i)^2+k2.^2+(k3+beta(i).*k1(i)).^2).^(17/6))); > F_33(count) = 4*integral2(phi_33,0,1000,0,1000); end > > Now let's come to my question. I know from a paper that: > > k = sqrt(k1.^2+k2.^2+k3.^2); > k30 = k3 + beta.*k1; > k0 = sqrt(k1.^2+k2.^2+k30.^2); > E_k0 = 1.453.*(k0.^4./((1+k0.^2).^(17/6))); > > Therefore the expression for phi_33 would result in > > phi_33 = (E_k0./(4*pi.*(k.^4))).*(k1.^2+k2.^2); > > The question is: how can I make use of this final expression insted of the > long one I'm using at the moment (within the for loop)?
You have a function for E that you can use to generate E_k0. Change your expressions for k, k30, and k0 into functions then call those functions in your phi_33 function.
k = @(k2, k3) sqrt(k1.^2+k2.^2+k3.^2); k30 = @(k2, k3) k3 + beta.*k1; k0 = @(k2, k3) sqrt(k1.^2+k2.^2+k30.^2); phi_33 = @(k2, k3) (E(k0(k2, k3))./(4*pi.*(k(k2, k3).^4))).*(k1.^2+k2.^2);
Note that saying E(k0) would NOT be sufficient; E doesn't operate on a function handle but on a numeric value, and so you need to evaluate the k0 function and pass the result it returns into the E function.
k1 also needs to be defined before you define ANY of these functions; the function handles will "remember" the value of k1 that existed when they were created.
 Steve Lord slord@mathworks.com To contact Technical Support use the Contact Us link on http://www.mathworks.com



