A simulink block function for definite integral

Hi,
How can i create a definite integral function block with 4 inputs (1st is the function that i want integrate, 2nd is the function "respect to" i want integrate and 3rd and 4th are variable integration bounds) ???
I tried with an Embedded Matlab Funcion:
function y = (f,x,a,b)
y=int(f,x,a,b);
where f is the function to integrate, x is "respect to" function; "a" and "b" are variable integration bounds and where "a" and "b" are x-elements . EML goes to error and says "This call-site passes more inputs to this function that it can accept. ...".
The problem is that Simulink Integrator Block outputs the integral of its input respect time only and most of all it has not inputs to change integration bounds. Instead i need an "universal and definite" integrator block to integrate any function respect to any function and where can i set as input integration bounds.

Risposte (3)

You can do the pulse trick
fun-----------------------------I
Product -----> Integrator
step(time=b)----> - sum --------I
+
step(time=a)--------I
Make a subsystem with those blocks and a nice mask for the user to insert a and b
The only part that's missing is the "respect to" function, it's always t

1 Commento

How can i fit final values of the steps as inputs of the subsystem?

Accedi per commentare.

Mark
Mark il 28 Feb 2011
I think that your best bet would be to use an Embedded MATLAB block for the integration. However, there is one obstacle, which is that there is no "character" or "variable name" data type in Simulink, so there is no real way to make the variable of integration an input.
In a bigger sense, even if the block could accept such an input, it might not be very useful because there would be no other blocks to produce it.
An alternative, would be to have the block use a parameter or refer to a MATLAB base workspace variable that happens to have character data inside of it. This would likely require some use of both the "extrinsic" keyword in EML, as well as a few uses of "eval" and "feval".
Kaustubha Govind
Kaustubha Govind il 28 Feb 2011
Specifically to address the error: There are several MATLAB functions that are called "int" - you are using the function int from the Symbolic Math Toolbox, whereas, the int supported in Embedded MATLAB is from the Fixed-Point Toolbox and takes only one input. This is why you see the error.
Could you elaborate on how this arbitrary function 'f' is represented in Simulink?

4 Commenti

Well, i have a time-depending function f(t) to integrate respect to an other time-depending function s(t) ("respect to" means that the "ds" under integral must be take from s(t) ) from 0 to current value of s(t); therefore a parameter change.
I hope you understand what i have to do.
If your integration variable 's' is also a function of 't', then couldn't you just use integration by substitution (http://en.wikipedia.org/wiki/Integration_by_substitution) to express your desired integral as an integration over 't'?
And if i'm able to do it, how can i integrate to apply integration by substitution ?
How can i do it with EML ?
When you have expressed the integral in the equivalent "integral over t" form, you can compute this function for every input and pass into a Integrator block.

Accedi per commentare.

Richiesto:

il 28 Feb 2011

Community Treasure Hunt

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

Start Hunting!

Translated by