A and B must be floating-point scalars.

조회 수: 1 (최근 30일)
nikhil
nikhil 2020년 1월 31일
댓글: nikhil 2020년 2월 1일
i am trying to integrate this function and while solving this function i am getting an error as A and B must be floating point scalars
below is my code
R = 90; ro = 17.5; tht = asind(ro/R); b= 1.225*ro; b_bar = b/R; %tht is winding angle
r = ro:0.25:b;
ro_bar= ro/R;
k1 = 1/2*(sqrt((1+3*(ro_bar).^2)/(1-(ro_bar).^2))-1);
k2 = 1/2*(-sqrt((1+3*(ro_bar).^2)/(1-(ro_bar).^2))-1);
r_bar = r/R; r1 = b:5:R; r_bar1 = r1/R;
b_1 = r1/R;
k = sqrt ((1-k1)/(1-k2));
x= asind(sqrt((1-((r_bar).^2)))/(1- k1)) % sin(theta) from r0 to b
y = asind(sqrt((1-((b_1).^2)))/(1- k1)); % sin(theta_star)from b to R
fun = @(x)1./(sqrt(1-(1.3742*(sin(x).*sin(x)))));
i = integral (fun, x, 0, t);

채택된 답변

Sergey Kasyanov
Sergey Kasyanov 2020년 1월 31일
Hello,
You need to replace i = integral (fun, x, 0, t); to one of variants below:
If you want to integrate in x range (from x(1) to x(end)) try that:
i = 0;
for c=1:length(x)
i = i + integral(fun,x(c),x(c+1));
end
If you want to take some integrals in range 0 to x(i) for each i try that:
i = zeros(size(x));
for c = 1:length(x)
i(c) = integral(fun,0,x(c));
end
  댓글 수: 1
nikhil
nikhil 2020년 2월 1일
Thanks Sergey kasyanov for your time and code is working is perfectly

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by