0

Hello and thanks for reading this: This question is regarding Matlab:

I need integrate this expression of two variables

w1=subs(diff(K,Y1),{Y1,Y2},{0.2,0.3})

where K is defined as a handle function:

K=@(X1,X2,Y1,Y2)...

so w1 is a ''function'' of two variables but Matlab says that

''Undefined function or method 'matlabfunction' for input arguments of type 'sym' ''

If I ask for K or w1

which w1

Matlab returns

''w1 is a variable''

When I use dblquad the error message is

''If FUN is a MATLAB object, it must have an feval method.''

I know that Matlab is right but how can I obtain the (double) integrate of w1 in the unit square?

I have tried a lot of things but I don't get it.

Can anyone help me?

Joe C
  • 15,324
  • 8
  • 38
  • 50
Benigno
  • 3
  • 2

1 Answers1

0

I'm not completely sure which variables in your code are defined as symbolic, but here's a minimal example.

Suppose I have a function handle of the kind:

x = @(t, a) t*a*a;

If I define:

syms t a;

I can get a symbolic derivative while substituting a value like in your code:

f = subs(diff(x(t, a), a), a, 3);

Note that f is now a symbolic variable. To convert this variable into a function handle you can use matlabFunction like so:

fun = matlabFunction(f);

Hope this helps.

Yuri Lifanov
  • 347
  • 1
  • 2
  • 11