Filter löschen
Filter löschen

A and B must be floating-point scalars.

1 Ansicht (letzte 30 Tage)
K Dani
K Dani am 18 Apr. 2018
Beantwortet: Walter Roberson am 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?

Antworten (1)

Walter Roberson
Walter Roberson am 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)

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by