Sum of functions with function handle
Show older comments
I have problems to understand function handle @. I have been away from Matlab for many years (almost 20 years) and now I’m back as a supervisor in a FEM-course. I’m trying to use my old code, but I never used function handles and to integrate we used a function called quad and called the function to be integrated by a string. Now to the problem: I have a function which contains the functions to be integrated:
function [dnhdn] = dnhdn(r,c,x)
global ata
dnhdn= dshape(r,x).*(((height(x)).^3)/(12*ata)).*dshape(c,x);
height is a function of x for ex. h=h0*exp(-10*x); dshape is a shapefuntion of x (an array with three alternative assign by r and c)
function [Be] = dshape(i,x)
% The function calculate the differated shapefunctions for the quadratic
% element.
global xi xj xk L
Be1=[(2/L^2)*(2*x-xj-xk);(-4/L^2)*(2*x-xi-xk);(2/L^2)*(2*x-xi-xj)];
Be=Be1(i,:);
dnhdn is the function to be integrated.
Using q = integral(fun,xmin,xmax) Fun must be assign with function handle, @(x). How do I manage to make a function with function handle from a product of several function? My fun is going to be dnhdn and I really like to have height and dshape in separate functions. I hope that someone understand my question and I'm looking forward to an answer. Please add a simple code just to clarify how to do. Best regard /Madeleine
Accepted Answer
More Answers (0)
Categories
Find more on MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!