How to solve error using integral (line 83) first input argument must be a function handle?

It is necessary to calculate the function "z" and its values, to build a 3D graph depending on "x" and "y".
I enter commands:
xi=0.062
m=64
[x,y,ksi]=meshgrid(-1:0.1:1,2:0.2:10,-1:0.1:1)
y1=((sign((x./y)+ksi).*((1+xi)./2)+((1-xi)./2)).*((x./y)+ksi ))^m
z=(integral(y1,0,1)).^(1./m)
After the last command it gives an error:
error using integral (line 83)
first input argument must be a function handle
Tell me, what's the problem?

3 Comments

What is the integration variable in y1 (thus the variable with respect to which you want to integrate from 0 to 1) ?
I'm sorry, the comment did not go, I did not notice.
The integration variable in y1 is ksi.
ksi = t/T
In its original form it looks like this:
T=1
t=0:1

Sign in to comment.

 Accepted Answer

T = 1;
m = 64;
x = 1:0.1:2;
y = 2:0.2:10;
[X,Y] = meshgrid(x,y);
g = @(u)sin(2*pi*u);
phi = @(t,x,y) ((sign(x/y+g(t/T)).*(1+t/T)/2+(1-t/T)/2).*(x/y+g(t/T))).^m;
sol = (arrayfun(@(x,y)1/T*integral(@(t)phi(t,x,y),0,1),X,Y)).^(1/m)
sol = 41×11
1.4358 1.4841 1.5323 1.5806 1.6289 1.6772 1.7255 1.7738 1.8221 1.8704 1.9188 1.3920 1.4358 1.4797 1.5235 1.5674 1.6113 1.6552 1.6991 1.7430 1.7869 1.8309 1.3554 1.3956 1.4358 1.4760 1.5162 1.5565 1.5967 1.6369 1.6772 1.7174 1.7577 1.3245 1.3616 1.3987 1.4358 1.4729 1.5100 1.5472 1.5843 1.6214 1.6586 1.6957 1.2981 1.3325 1.3669 1.4014 1.4358 1.4703 1.5047 1.5392 1.5737 1.6082 1.6427 1.2751 1.3072 1.3394 1.3715 1.4037 1.4358 1.4680 1.5001 1.5323 1.5645 1.5967 1.2550 1.2851 1.3153 1.3454 1.3755 1.4057 1.4358 1.4660 1.4961 1.5263 1.5565 1.2373 1.2657 1.2940 1.3224 1.3507 1.3791 1.4074 1.4358 1.4642 1.4926 1.5210 1.2216 1.2483 1.2751 1.3019 1.3287 1.3554 1.3822 1.4090 1.4358 1.4626 1.4894 1.2075 1.2328 1.2582 1.2836 1.3089 1.3343 1.3597 1.3851 1.4104 1.4358 1.4612

3 Comments

I'm very grateful to you! This allowed me to move forward. So far the result is a bit different than I expected. Also, I did not quite understand the turns in the arrayfun function. I will look into this feature soon.
Can you please tell me why in the function arrayfun 1/T?
I'm a little bit confused about your t/T with respect to which you integrate.
According to your notation, my guess is that the integral should be
m = 64;
x = 1:0.1:2;
y = 2:0.2:10;
[X,Y] = meshgrid(x,y);
g = @(u)sin(2*pi*u);
phi = @(ksi,x,y) ((sign(x/y+g(ksi)).*(1+ksi)/2+(1-ksi)/2).*(x/y+g(ksi))).^m;
sol = (arrayfun(@(x,y)integral(@(ksi)phi(ksi,x,y),0,1),X,Y)).^(1/m)
sol = 41×11
1.4358 1.4841 1.5323 1.5806 1.6289 1.6772 1.7255 1.7738 1.8221 1.8704 1.9188 1.3920 1.4358 1.4797 1.5235 1.5674 1.6113 1.6552 1.6991 1.7430 1.7869 1.8309 1.3554 1.3956 1.4358 1.4760 1.5162 1.5565 1.5967 1.6369 1.6772 1.7174 1.7577 1.3245 1.3616 1.3987 1.4358 1.4729 1.5100 1.5472 1.5843 1.6214 1.6586 1.6957 1.2981 1.3325 1.3669 1.4014 1.4358 1.4703 1.5047 1.5392 1.5737 1.6082 1.6427 1.2751 1.3072 1.3394 1.3715 1.4037 1.4358 1.4680 1.5001 1.5323 1.5645 1.5967 1.2550 1.2851 1.3153 1.3454 1.3755 1.4057 1.4358 1.4660 1.4961 1.5263 1.5565 1.2373 1.2657 1.2940 1.3224 1.3507 1.3791 1.4074 1.4358 1.4642 1.4926 1.5210 1.2216 1.2483 1.2751 1.3019 1.3287 1.3554 1.3822 1.4090 1.4358 1.4626 1.4894 1.2075 1.2328 1.2582 1.2836 1.3089 1.3343 1.3597 1.3851 1.4104 1.4358 1.4612
which is a little different from which I posted first (at least for T not equal to 1).

Sign in to comment.

More Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Products

Release

R2013a

Tags

Asked:

on 20 Jan 2023

Edited:

on 28 Feb 2023

Community Treasure Hunt

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

Start Hunting!