How to perform differentiation in MATLAB?
2 次查看(过去 30 天)
显示 更早的评论
I have the following function.
The F is a 1*4 matrix and it is given. w=2*pi*f where f=50 Hz. I need to find out the value of i. How can I write the code in MATLAB?
24 个评论
Torsten
2022-9-14
So you have to solve
F = 2/pi * pi/2 * i^2 * omega
for i ? Should be no problem, shouldn't it ?
Image Analyst
2022-9-14
Looks like integration. Where is this differentiation you're asking about? Can you attach your existing script with the paper clip icon? And if F came from somewhere, like a .mat file, attach that too.
Walter Roberson
2022-9-14
Does the mean the derivative with respect to w times t? If so, that complicates matters: MATLAB's int() function can only integrate with respect to a variable, so a change of variables would need to be done
w is scalar, presumably t is scalar. So if F is 1 x 4, the implication would have to be that is 1 x 4. But is which would be inner product of i with itself, which would fail for 1 x 4 vector i.
ANANTA BIJOY BHADRA
2022-9-14
I have the F value provided in the image. I need to find the i using the integral equation also given in the attched image.
But I need to do that using the matlab code.
ANANTA BIJOY BHADRA
2022-9-14
Can you elaborate how do you get i = sqrt(F/omega)? Actually, I am not getting the exact idea.
Walter Roberson
2022-9-14
I do not think that is correct. That would be correct if the equation were int(i^2*w*t, t, 0, pi/2) but it is int(i^2, w*t, 0, pi/2) where the integration is with respect to w*t not with respect to t. It needs a change of variables, which would affect the integration bounds.
Walter Roberson
2022-9-15
I think the integral needs a change of variables from integral of i^2 d_wt over wt 0 to π/2, to become 1/w * integral of i^2 * du over u 0 to w*π/2.
That should then be 1/w * (i^2*u over 0 to w*π/2) which would be 1/w * (i^2 * (w*π/2 - 0)) which should work out to π/2*i^2
The complete formula multiplies by 2/π so that cancels the π/2 leaving just i^2
So the question then becomes to solve F = i^2
Dyuman Joshi
2022-9-15
But w (omega) is given to be a constant here. So d(wt) should become w*d(t).
I guess OP needs to confirm this.
Walter Roberson
2022-9-15
No, the derivative is not with respect to t, the derivative is with respect to ωt so the question is not how quickly i^2 changes with respect to t, but rather how quickly it changes with respect to ω*t
ANANTA BIJOY BHADRA
2022-9-15
The derivative is respect to (omega*t), not t. Actually it is integration of a nonlinear function. But I know th value of F at any instance, I need to calculate the value of i. The relation between F and i are in integral form. I have attached another image for clarification.
ANANTA BIJOY BHADRA
2022-9-15
lambda is the flux. actually it is a saturation curve. I can get the values of lambda from another equation. But it was not possilble for me to extract the value of i from the integral equation. I know the value of F at any instant. Using the value of F and the integral equation that I have shared, I need to find the value of i. I hope I was able to clarify.
ANANTA BIJOY BHADRA
2022-9-15
F comes from an array. If you see the previous image, you can see the value of F and 4 instance. I need to find the value of i at those four instance using the integral equation. the omega=2*pi*f whwre f=50Hz. The flux has nothing to do with i. For testing purpose, I have a known set of i which is generated from the F. See the below values:
F=[0 0.4409 1.1809 3.1570]
i=[0 0.6235 2.7238 7.2487]
Torsten
2022-9-15
编辑:Torsten
2022-9-15
Because you didn't answer my questions satisfactory, I'll show you how to proceed to recover i if F is given by
F(x) = integral_{y=0}^{y=x} i^2(y) dy
Say at 0=y(1)<y(2)<...<y(n) you have values for F of the above equation and you search for i.
Then - with the help of the trapezoidal rule - you get
i(1) = 0
F(2) = (y(2)-y(1))*(i^2(1)+i^2(2))/2 -> i^2(2) = 2*F(2)/(y(2)-y(1)) - i^2(1) ->
i(2) = sqrt(F(2)*2/(y(2)-y(1)) - i^2(1))
F(3) = (y(2)-y(1))*(i^2(1)+i^2(2))/2 + (y(3)-y(2))*(i^2(2)+i^2(3))/2 = F(2) + (y(3)-y(2))*(i^2(2)+i^2(3))/2 -> (F(3)-F(2))*2 / (y(3)-y(2)) - i^2(2) = i^2(3) ->
i(3) = sqrt((F(3)-F(2))*2 / (y(3)-y(2)) - i^2(2))
In general you get the recursion
i(1) = 0
i(k+1) = sqrt((F(k+1)-F(k))*2 / (y(k+1)-y(k)) -i^2(k))
to recover i from F.
Walter Roberson
2022-9-15
Consider
The integral from 0 to 1 of the constant 1 with respect to a quantity should obviously be 1. But if you say that d(5t) = 5*dt then you would integrate which would give you the result 5 rather than 1. So you have to change to as then the integral would be 5 and you would multiply that by the outer 1/5 to get an overall result of 1.
Torsten
2022-9-16
编辑:Torsten
2022-9-16
Did you read the Wikipedia page about Riemann Stietjes integrals ?
It's explicitly written there that integral_{x=a}^{x=b} f(x) dg(x) = integral_{x=a}^{x=b} f(x) g'(x) dx.
Thus for the above integral integral_{x=0}^{x=1} 1 d(5*x) = integral_{x=0}^{x=1} 1*5 dx = 5.
But I think for the OP omega*t is just an integration variable u. Thus
integral_{omega*t=0}^{omega*t=pi/2} i^2(omega*t) d(omega*t) = integral_{u=0}^{u=pi/2} i^2(u) du
Chunru
2022-9-16
编辑:Chunru
2022-9-16
It seems that the notation of is ambigous for definite integral and the notation is not widely used (correct me if I am wrong) since one does not know whether the integral limit is for variable x or for function . To make it clear, one can write but it is cumbersome. Of course, there is no issue for indefinete integration where integral limits are not relevant.
So we must understand the convention used.
where integral limits are for t and not for or .
The expression is clear enough and we know the integral limits are for variable t.
But I am not sure whether this is a general convention.
Torsten
2022-9-16
编辑:Torsten
2022-9-16
It's the general convention - the independent variable (limit of integration) is always x (or t).
The form of integral is often used in measure theory where integration usually is with respect to general measures, not only with respect to Lebesgue-measure (which is the usual integration (dx)).
E.g. for a random variable X with cumulative distribution function F(x), one often writes
P(X<=x) = integral_{y=-oo}^{y=x} dF(y)
which means
P(X<=x) = integral_{y=-oo}^{y=x} f(y) dy
where f = F' is the probability density function of the random variable X.
But I doubt that the OP had this in mind - in my opinion, omega*t is just meant as one compact integration variable u:
integral_{omega*t=0}^{omega*t=pi/2} i^2(omega*t) d(omega*t) = integral_{u=0}^{u=pi/2} i^2(u) du
Torsten
2022-9-16
Maybe you could show us how you compute F given i
(e.g. for your example F=[0 0.4409 1.1809 3.1570], i=[0 0.6235 2.7238 7.2487]) )
回答(1 个)
Ganesh Gudipati
2022-9-21
Hi,
You can rewrite the equation you have in order to find "i". Then you use diff function.
Since "F" is an array in this case you have to perform for each element individually. So "i" will also end up as an array.
I hope this resolves your issue.
Thanks.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Mathematics and Optimization 的更多信息
标签
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!发生错误
由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
亚太
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)