Check for missing argument or incorrect argument data type in call to function 'int'.
显示 更早的评论
I want to write code for this integral function
but there is an error
but there is an error Check for incorrect argument data type or missing argument in call to function 'int'.
Error in nntraining3 (line 12)
P = int(f, x, 0, inf);

How can I improve it?
Pg = 0.198;
Pl = 0.818;
t = 1500;
y = Pg-Pl
f = abs(y);
P = int(f, t, 0, inf)
Can you check this code?
回答(1 个)
Walter Roberson
2022-5-25
P = inf(size(f));
P(f==0) = 0;
You are integrating a vector of non-negative real constants from 0 to infinity. The integral of a positive constant to infinity is infinity. The integral of 0 to infinity is 0.
I have to wonder what anything in the first part of the code matters; you ignore all those variables.
I have to wonder if what you really want is trapz(f)
4 个评论
Alexandr Lim
2022-5-25
Walter Roberson
2022-5-25
int() is anti-differentiation. The first parameter must be a symbolic function or symbolic expression. the second parameter must be a symbolic variable to integrate over.
Your code builds numeric values through line 6 calculating K and I. Then on lines 7 and 8 you build numeric vectors without referring to anything you calculated before that. You subtract the two numeric vectors, you take the abs of the resulting numeric vector. Then you ask to int() the numeric vector, with respect to the numeric variable x. It makes no sense to integrate with respect to a numeric value. If it did make sense, then you would be integrating constants and the integral of those is (upper minus lower) times constant. With infinite upper bound and constant known to not be negative, the result would be infinite except where the constant is 0.
Notice that the variables you construct above that point are not used, so they will not affect the results.
Walter Roberson
2022-5-25
Shallow Neural networks do not involve integration, they are transformation functions and matrix multiplication, done as many times as there are layers.
You could potentially want to model an infinite number of layers that were the same, and ask what the final value would be. I do not think that you would integrate for that: it would be more like calculating eigenvalues, doing calculations like infinite Markov chains.
Alexandr Lim
2022-5-26
类别
在 帮助中心 和 File Exchange 中查找有关 Numerical Integration and Differentiation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!