Clear Filters
Clear Filters

A and B must be floating-point scalars.

1 view (last 30 days)
K Dani
K Dani on 18 Apr 2018
Answered: Walter Roberson on 18 Apr 2018
I am trying to compute this function(as seen in the attachment) within a for loop but I keep getting an error. Here is my code so far
for n = 1:np
fun = @(br2, brend) (A0./Area).^(0.36)
chi = integral(fun,min(br2), max(brend))
plot(chi, Y)
end
I'm quite certain I just really don't understand how the integral function works or something. "br2" and "brend" are column vectors so I put the boundaries as the min(br2) and max(brend), which makes sense for what I am trying to compute. I think I'm getting the variable part wrong when defining the function to integrate?

Answers (1)

Walter Roberson
Walter Roberson on 18 Apr 2018

Your fun is a function of two variables, but integral is for functions of one variable.

Your fun is ignoring both inputs and returning a constant value.

Your br2 and brend would have to be numeric floating point values to use in the way you are. class(br2) and class(brend) would need to be 'single' or 'double'.

You are computing a single chi for each iteration, and using it as the x value for plotting Y, which is of unknown size. You might not get any output. You should probably be recording the chi results into a vector and plotting them afterwards, such as

chi(n) = integral(....);

and then after the loop,

plot(chi)

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!