フィルターのクリア

Hi all, i try to use interp1 function. but i have two data input (Y), the values of the underlying function , one of them is a vector while the other is constant value. so how i can deal with Y

2 ビュー (過去 30 日間)
yi = c(x,Y,xi)
  1 件のコメント
Stephen23
Stephen23 2016 年 2 月 20 日
What is c? Please show us what values you have, and how you want to use them.

サインインしてコメントする。

回答 (1 件)

John D'Errico
John D'Errico 2016 年 2 月 20 日
編集済み: John D'Errico 2016 年 2 月 20 日
So, what you are telling us is, that you apparently have a "function" Y(x), such that for ANY point x, the value of the function Y(x) is Y, a constant. You wish to interpolate that "function"?
My question is, why bother? You already know the function is constant. So the simple answer is to use repmat, which will return the same constant value for every value of xi.
yi = repmat(Y,size(xi));
The only thing I am unsure about is what you intended by the code fragment:
yi = c(x,Y,xi)
This is what Stephen also referred to. I see that this call seems to be identical to the format interp1 uses. And you refer to interp1 in your question. Therefore, I assume that you are asking what function can be used to interpolate a constant function. Again, the answer is, no special function is required, perhaps beyond something trivial like repmat.
  3 件のコメント
Muna Shehan
Muna Shehan 2016 年 2 月 21 日
where Y is a matrix that should contain the input of u (2xlength(x). So how i can write Y if it contains two inputs one of them is vary with time and the other is constant yi = interp1(x,Y,xi)
Jonathan Hawkins
Jonathan Hawkins 2017 年 6 月 12 日
As to "Why bother..." I've run into this problem when I'm writing code that needs to interpolate for a generic function, which can be constant.
It's incredibly irritating that interp1 throws an error if the function you're interpolating happens to be constant. That's just shoddy design on Mathworks' part if you ask me.

サインインしてコメントする。

カテゴリ

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

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by