Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Forming function handles in matrix

조회 수: 1(최근 30일)
Bathala Teja
Bathala Teja 2021년 10월 6일
마감: Stephen 2021년 10월 6일
I want to form array of function handles first.
After that i need to form 20*20 matrix by involving integration of these function handles.
I provided my script below, iam facing the below error.
Ginvi = @(phi)zeros(size(phi));
for i=2:10
Ginvi = @(phi)Ginvi(phi)+3.56*cos(2*i*(phi-1.5));
end
nr = cell(1, 20);
wr = cell(1, 20);
for j = 1:4
for n = (((j-1)*5)+2):(j*5)
nr{n} = @(phi)50*cos(phi+n*2)+32*2/3;
wr{n} = @(phi)50*cos(phi+n*2);
end
end
for n = 1:5:20
nr{n} = @(phi)60*cos(phi-3.56+(n-1)*5)+32*2/3;
wr{n} = @(phi)60*cos(phi-3.56+(n-1)*5);
end
nr
nr = 1×20 cell array
{@(phi)60*cos(phi-3.56+(n-1)*5)+32*2/3} {@(phi)50*cos(phi+n*2)+32*2/3} {@(phi)50*cos(phi+n*2)+32*2/3} {@(phi)50*cos(phi+n*2)+32*2/3} {@(phi)50*cos(phi+n*2)+32*2/3} {@(phi)60*cos(phi-3.56+(n-1)*5)+32*2/3} {@(phi)50*cos(phi+n*2)+32*2/3} {@(phi)50*cos(phi+n*2)+32*2/3} {@(phi)50*cos(phi+n*2)+32*2/3} {@(phi)50*cos(phi+n*2)+32*2/3} {@(phi)60*cos(phi-3.56+(n-1)*5)+32*2/3} {@(phi)50*cos(phi+n*2)+32*2/3} {@(phi)50*cos(phi+n*2)+32*2/3} {@(phi)50*cos(phi+n*2)+32*2/3} {@(phi)50*cos(phi+n*2)+32*2/3} {@(phi)60*cos(phi-3.56+(n-1)*5)+32*2/3} {@(phi)50*cos(phi+n*2)+32*2/3} {@(phi)50*cos(phi+n*2)+32*2/3} {@(phi)50*cos(phi+n*2)+32*2/3} {@(phi)50*cos(phi+n*2)+32*2/3}
lrr = ones(20, 20);
for i = 1:20
for j = 1:20
lrr(i, j) = 55*integral(@(phi)(nr{i}*wr{j}*Ginvi(phi)), 0, 2*pi);
end
end
Operator '*' is not supported for operands of type 'function_handle'.

Error in solution (line 24)
lrr(i, j) = 55*integral(@(phi)(nr{i}*wr{j}*Ginvi(phi)), 0, 2*pi);

Error in integralCalc/iterateScalarValued (line 314)
fx = FUN(t);

Error in integralCalc/vadapt (line 132)
[q,errbnd] = iterateScalarValued(u,tinterval,pathlen);

Error in integralCalc (line 75)
[q,errbnd] = vadapt(@AtoBInvTransform,interval);

Error in integral (line 87)
Q = integralCalc(fun,a,b,opstruct);
lrr

답변(0개)

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by