You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
How to perform differentiation in MATLAB?
2 views (last 30 days)
Show older comments
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 Comments
Image Analyst
on 14 Sep 2022
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
on 14 Sep 2022
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
on 14 Sep 2022
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
on 14 Sep 2022
Can you elaborate how do you get i = sqrt(F/omega)? Actually, I am not getting the exact idea.
Walter Roberson
on 14 Sep 2022
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
on 15 Sep 2022
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
on 15 Sep 2022
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
on 15 Sep 2022
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
Torsten
on 15 Sep 2022
Edited: Torsten
on 15 Sep 2022
As far as I know, the rule
integral_{a}^{b} f(x) d(h(x)) = integral_{a}^{b} f(x) * dh/dx dx
is valid.
This would give
d(omega*t) = omega dt.
Nevertheless, I'm uncertain about what the OP really wants.
ANANTA BIJOY BHADRA
on 15 Sep 2022
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
on 15 Sep 2022
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
on 15 Sep 2022
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
on 15 Sep 2022
Edited: Torsten
on 15 Sep 2022
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
on 15 Sep 2022
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
on 16 Sep 2022
Edited: Torsten
on 16 Sep 2022
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
on 16 Sep 2022
Edited: Chunru
on 16 Sep 2022
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
on 16 Sep 2022
Edited: Torsten
on 16 Sep 2022
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
Answers (1)
Ganesh Gudipati
on 21 Sep 2022
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.
See Also
Categories
Find more on Mathematics and Optimization in Help Center and File Exchange
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- 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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)