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

 채택된 답변

Walter Roberson
Walter Roberson 2016년 7월 24일

0 개 추천

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

Madeleine Hermann
Madeleine Hermann 2016년 7월 24일
Thanks, very easy. Here a found problem that did not exist. Madeleine

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 MATLAB에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by