이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
How to perform differentiation in MATLAB?
조회 수: 3 (최근 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 (한국어)