필터 지우기
필터 지우기

Solving a differential equation using matlab

조회 수: 2 (최근 30일)
Andreas Volden
Andreas Volden 2014년 10월 14일
댓글: Star Strider 2014년 10월 15일
Hi!
I have the following differential equation where x is unknown and p_dot is the derivative of p(p is given):
x * p_dot = qa -qb.
The vectors qa, qb and p are given by samples of 1 sec, and n samples. In this case n = 3597.
To find x, I've tried several procedures, none that actually works. One challenge for me is to find the derivative of p. Using both matlab and simulink has given me no logical answers. I've also tried the other way around, by integrating both sides of the equal sign. This also gives faulty answers.
Anyone who can provide som hint/tips, especialy some coding examples, would be appreciated!
Cheers

채택된 답변

Star Strider
Star Strider 2014년 10월 15일
I am not certain that I understand what you want to do, so see if this approximates it:
p = linspace(0,50,25) + rand(1,25)*0.01; % Create Data
qa = randi(10,1,25); % Create Data
qb = randi(20,1,25); % Create Data
p_dot = gradient(p); % Create ‘p_dot’
x = (qa - qb)./p_dot; % Solve For ‘x’
  댓글 수: 2
Andreas Volden
Andreas Volden 2014년 10월 15일
Thanks for replying!
I have tried your procedure without any luck. I may have been unclear in my formulation, let me rephrase: I know the x in this case is a constant while p, qa and qb varies.
When i calculate x straight forward like you suggest, x varies a lot over the elements in the [nx1] vector it becomes.
I have tried to solve it only when values in the terms (qa-qb) and p_dot is nonzero. The vectors then becomes shorter, like: [n-jx1]. Even then, my x varies a lot. Any further tips?
Star Strider
Star Strider 2014년 10월 15일
My pleasure!
Without knowing more about your data and what you want to do, I cannot be specific. (A sample of your data would be helpful.) If x is supposed to be a constant, one possibility might be to do a linear regression, for instance:
x = [ones(size(p))' p_dot']\[qa' - qb']; % Solve For ‘x’
This replaces my previous line calculating ‘x’. It gives two scalar values, a slope ‘x(1)’ and an intercept ‘x(2)’, but it might be what you want. Note that this assumes all your original vectors are row vectors, so they need to be transposed to column vectors to work in the regression equation (thus the transpose (') operators).
Does this do what you want?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Support Vector Machine Regression에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by