A simulink block function for definite integral

17 views (last 30 days)
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.

Answers (3)

Paulo Silva
Paulo Silva on 28 Feb 2011
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 Comment
cyberdyne
cyberdyne on 26 Mar 2011
How can i fit final values of the steps as inputs of the subsystem?

Sign in to comment.


MarkB
MarkB on 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 on 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 Comments
cyberdyne
cyberdyne on 1 Mar 2011
And if i'm able to do it, how can i integrate to apply integration by substitution ?
How can i do it with EML ?
Kaustubha Govind
Kaustubha Govind on 15 Mar 2011
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.

Sign in to comment.

Categories

Find more on General Applications 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!