Problem using interp1 cubic

I`m trying to inter a grapich but it`s wrong im using interp1 cubic
How should be
It looks wrong
Help.
Edit [21 Aug 2012, 12:45 BST - OK] Added Alex's answer here
x1=[ 1.0000 6.1000 10.1800 135.3000 136.5750....86.7650 83.2800]
y1=[ 1 23 40...... 2144 2152]
s=[1:0.1:95]
z=interp1(x1,y1,s,'cubic')
plot(s,z)

6 件のコメント

Azzi Abdelmalek
Azzi Abdelmalek 2012 年 8 月 21 日
post your data
Jan
Jan 2012 年 8 月 21 日
How could we find out, what is wrong with the command you have used to create the wrong diagram without seeing the code? A suggestion for improvements must be based on wild guessing.
Oleg Komarov
Oleg Komarov 2012 年 8 月 21 日
@Alex: please use comments, do NOT create additional answers unless it is an answer to your problem.
Alex
Alex 2012 年 8 月 21 日
ok sorry
Oleg Komarov
Oleg Komarov 2012 年 8 月 21 日
I think the problem is that it's not a function, i.e. you have multiple Ys for an X.
As Jose pointed out you might transpose the x with the y, interpolate and then re-transpose back.
Alex
Alex 2012 年 8 月 21 日
I try interp1(y1,x1,s,'cubic') but is the same image than jose's answer

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

回答 (2 件)

José-Luis
José-Luis 2012 年 8 月 21 日

2 投票

Try inverting your x y data
interp1(x,y,...) to interp1(y,x,...)
Cheers!

2 件のコメント

Jan
Jan 2012 年 8 月 21 日
Alex wrote: (Copied from Answer to the comment section:)
Don`t work
Jan
Jan 2012 年 8 月 21 日
Posting the problem and further explanations by picture only is not efficient. We cannot reproduce your diagrams when you do not provide the data. Perhaps only your drawing method fails?!

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

Titus Edelhofer
Titus Edelhofer 2012 年 8 月 21 日

1 投票

Hi,
the plot shows that it's not a function y = f(x) and also not a function x = g(y). So you will need to move to a 2D parametrization. Take a look at the function spline that can handle the case of an arbitrary trajectory in the plane, e.g. take a look at example 4 (the cirlce).
Titus

3 件のコメント

Titus Edelhofer
Titus Edelhofer 2012 年 8 月 21 日
I took another look at the image. The transpose should work, so ignore my answer ...
Alex
Alex 2012 年 8 月 21 日
編集済み: Alex 2012 年 8 月 21 日
only a part work
Alex
Alex 2012 年 8 月 21 日
its works i need change s=[1:0.1:95] when i transpose x and y to s=[1:0.1:2152]

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

カテゴリ

ヘルプ センター および File ExchangeGraphics Performance についてさらに検索

タグ

質問済み:

2012 年 8 月 21 日

Community Treasure Hunt

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

Start Hunting!

Translated by