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

 Réponse acceptée

Walter Roberson
Walter Roberson le 24 Juil 2016
If r and c are constants relative to the integration, and x is the variable of integration, then:
fun = @(x) dnhdn(r, c, x);

1 commentaire

Madeleine Hermann
Madeleine Hermann le 24 Juil 2016
Thanks, very easy. Here a found problem that did not exist. Madeleine

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB dans Centre d'aide et File Exchange

Tags

Aucun tag saisi pour le moment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by