フィルターのクリア

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 Center および File ExchangeSupport Vector Machine Regression についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by