フィルターのクリア

Writing Coefficients of a Summation?

13 ビュー (過去 30 日間)
amateurintraining
amateurintraining 2017 年 9 月 22 日
回答済み: Image Analyst 2017 年 9 月 22 日
So, I have a quadratic function that is a summation. And the coefficients are the same, save for the first one but the powers are the powers from n_t to n_t-1.
To clarify: P*x^n_t - R*x^0 - R*x^1 ... - R*x^(n_t-1)
with coefficients: [P, -R, -R, ... , -R]
and powers: [n_t:n_t-1]
How do I write the coefficients in a way Matlab recognizes it?

回答 (3 件)

James Tursa
James Tursa 2017 年 9 月 22 日
編集済み: James Tursa 2017 年 9 月 22 日
For use with MATLAB functions like polyval and friends, the highest power coefficient is the first element on down to the constant term which is the last element. So you should build your coefficient vector as
n_t = whatever;
coef = [P,-R*ones(1,n_t)];

Star Strider
Star Strider 2017 年 9 月 22 日
See if this does what you want:
n = 6; % Arbitrary Constant
P = 3; % Arbitrary Constant
R = 5; % Arbitrary Constant
coefv = [P -R*ones(1, n)]; % Coefficient Vector
xpntv = [n 0:n-1]; % Exponent Vector
x = 4.2; % Scalar Value For ‘x’
S = (x.^xpntv) .* coefv; % Series

Image Analyst
Image Analyst 2017 年 9 月 22 日
Let's say, n_t is 5. Then (n_t - 1) is 4. Since you always go from n_t down to n_t-1, you always have only two terms, in this case an x^5 term and an x^4 term. But this does not make it a quadratic just because it has two terms. To be a quadratic, the highest term should be 2. So you can just make your coefficient array like
coefficient = [P, R];
And your output, for my example would be
y = P * x^5 + R * x^4;
I don't see any real need to make an array for the coefficients when you have only two of them.

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by