A and B must be floating-point scalars.

1 Ansicht (letzte 30 Tage)
nikhil
nikhil am 31 Jan. 2020
Kommentiert: nikhil am 1 Feb. 2020
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);

Akzeptierte Antwort

Sergey Kasyanov
Sergey Kasyanov am 31 Jan. 2020
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 Kommentar
nikhil
nikhil am 1 Feb. 2020
Thanks Sergey kasyanov for your time and code is working is perfectly

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by