A simulink block function for definite integral

17 次查看(过去 30 天)
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.

回答(3 个)

Paulo Silva
Paulo Silva 2011-2-28
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

MarkB
MarkB 2011-2-28
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 2011-2-28
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 个评论
cyberdyne
cyberdyne 2011-3-1
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 2011-3-15
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 General Applications 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by