How does interp1 work? (2024)

29 Ansichten (letzte 30 Tage)

Ältere Kommentare anzeigen

massi am 7 Apr. 2015

  • Verknüpfen

    Direkter Link zu dieser Frage

    https://de.mathworks.com/matlabcentral/answers/196538-how-does-interp1-work

  • Verknüpfen

    Direkter Link zu dieser Frage

    https://de.mathworks.com/matlabcentral/answers/196538-how-does-interp1-work

Kommentiert: John D'Errico am 21 Jun. 2018

In MATLAB Online öffnen

Hello, I am not understanding why this little program for interpolation of sin(x) changing the number of points, is not working. Could you help me, please?

x = 0:10;

y = sin(x);

xi = 0:.25:10;

yi = interp1(x,y,xi);

plot(x,y,'o',xi,yi)

Thanks Bye massi

1 Kommentar

-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden

Geoff Hayes am 7 Apr. 2015

Direkter Link zu diesem Kommentar

https://de.mathworks.com/matlabcentral/answers/196538-how-does-interp1-work#comment_277126

  • Verknüpfen

    Direkter Link zu diesem Kommentar

    https://de.mathworks.com/matlabcentral/answers/196538-how-does-interp1-work#comment_277126

Massi - please clarify what you mean by is not working. Are you suggesting that if you change the number of points then there is no change to the plot? Re you expecting a better solution if you increase the number of points?

Melden Sie sich an, um zu kommentieren.

Melden Sie sich an, um diese Frage zu beantworten.

Antworten (3)

  • Verknüpfen

    Direkter Link zu dieser Antwort

    https://de.mathworks.com/matlabcentral/answers/196538-how-does-interp1-work#answer_174323

  • Verknüpfen

    Direkter Link zu dieser Antwort

    https://de.mathworks.com/matlabcentral/answers/196538-how-does-interp1-work#answer_174323

In MATLAB Online öffnen

Default interpolation is linear. If you add in 3 points between every pair of points and then linearly interpolate you will just get extra points on the same lines that you had before.

'spline' or 'pchip' will provide some difference.

interpolating a function like that seems a waste of time though as sin(x) itself will do the interpolation job if rerun as:

yi = sin(xi);

1 Kommentar

-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden

massi am 7 Apr. 2015

Direkter Link zu diesem Kommentar

https://de.mathworks.com/matlabcentral/answers/196538-how-does-interp1-work#comment_277142

  • Verknüpfen

    Direkter Link zu diesem Kommentar

    https://de.mathworks.com/matlabcentral/answers/196538-how-does-interp1-work#comment_277142

yes thank you, I did it only to try if I am using this function correctly, but I obtain every time the following error:

Error in interpol (line 4) yi = interp1(x,y,xi);

Melden Sie sich an, um zu kommentieren.

John D'Errico am 7 Apr. 2015

  • Verknüpfen

    Direkter Link zu dieser Antwort

    https://de.mathworks.com/matlabcentral/answers/196538-how-does-interp1-work#answer_174330

  • Verknüpfen

    Direkter Link zu dieser Antwort

    https://de.mathworks.com/matlabcentral/answers/196538-how-does-interp1-work#answer_174330

Bearbeitet: John D'Errico am 7 Apr. 2015

In MATLAB Online öffnen

DON'T name a script (or function) interp1. Don't replace existing tools in MATLAB, as then you will later have problems, just like this.

You clearly did so, in a way that apparently calls interpol, a tool that you found on the file exchange. See that this is the error message fragment that is reported by you. It clearly mentions interpol, as called by interp1. In fact, interp1 NEVER calls a function that they don't supply.

"Error in interpol (line 4) yi = interp1(x,y,xi);"

So now you are asking how interp1 works, but really, it is using interpol, a perhaps lesser quality tool that you got from the FEX.

Try these things, and see what it gives you.

which interp1 -all

which interpol -all

type interp1

1 Kommentar

-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden

massi am 7 Apr. 2015

Direkter Link zu diesem Kommentar

https://de.mathworks.com/matlabcentral/answers/196538-how-does-interp1-work#comment_277147

  • Verknüpfen

    Direkter Link zu diesem Kommentar

    https://de.mathworks.com/matlabcentral/answers/196538-how-does-interp1-work#comment_277147

OK thank you very much

Melden Sie sich an, um zu kommentieren.

Mritu Sivaraman am 21 Jun. 2018

  • Verknüpfen

    Direkter Link zu dieser Antwort

    https://de.mathworks.com/matlabcentral/answers/196538-how-does-interp1-work#answer_325705

  • Verknüpfen

    Direkter Link zu dieser Antwort

    https://de.mathworks.com/matlabcentral/answers/196538-how-does-interp1-work#answer_325705

Can anyone explain me how this interp function works? Thanks

2 Kommentare

Keine anzeigenKeine ausblenden

Walter Roberson am 21 Jun. 2018

Direkter Link zu diesem Kommentar

https://de.mathworks.com/matlabcentral/answers/196538-how-does-interp1-work#comment_581159

  • Verknüpfen

    Direkter Link zu diesem Kommentar

    https://de.mathworks.com/matlabcentral/answers/196538-how-does-interp1-work#comment_581159

interp1() offers a number of different interpolation methods. Which one are you interested in?

Also, is the question about interp1() or about interp2()?

John D'Errico am 21 Jun. 2018

Direkter Link zu diesem Kommentar

https://de.mathworks.com/matlabcentral/answers/196538-how-does-interp1-work#comment_581179

  • Verknüpfen

    Direkter Link zu diesem Kommentar

    https://de.mathworks.com/matlabcentral/answers/196538-how-does-interp1-work#comment_581179

In MATLAB Online öffnen

There are MANY methods inside interp1:

'linear' - (default) linear interpolation

'nearest' - nearest neighbor interpolation

'next' - next neighbor interpolation

'previous' - previous neighbor interpolation

'spline' - piecewise cubic spline interpolation (SPLINE)

'pchip' - shape-preserving piecewise cubic interpolation

'cubic' - same as 'pchip'

'v5cubic' - the cubic interpolation from MATLAB 5, which does not

extrapolate and uses 'spline' if X is not equally

spaced.

'makima' - modified Akima cubic interpolation

To answer this question could take many hours to write. Some of those methods are alone worth many hours to write a complete explanation. So, if you want to understand interp1, then read the documentation for interp1. At the end, you will find references.

Or, ask a SPECIFIC question, about a SPECIFIC method in interp1.

Melden Sie sich an, um zu kommentieren.

Melden Sie sich an, um diese Frage zu beantworten.

Siehe auch

Kategorien

MATLABMathematicsInterpolation

Mehr zu Interpolation finden Sie in Help Center und File Exchange

Tags

  • interpolation

Community Treasure Hunt

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

Start Hunting!

Es ist ein Fehler aufgetreten

Da Änderungen an der Seite vorgenommen wurden, kann diese Aktion nicht abgeschlossen werden. Laden Sie die Seite neu, um sie im aktualisierten Zustand anzuzeigen.


Translated by How does interp1 work? (10)

How does interp1 work? (11)

Website auswählen

Wählen Sie eine Website aus, um übersetzte Inhalte (sofern verfügbar) sowie lokale Veranstaltungen und Angebote anzuzeigen. Auf der Grundlage Ihres Standorts empfehlen wir Ihnen die folgende Auswahl: .

Sie können auch eine Website aus der folgenden Liste auswählen:

Amerika

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europa

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom(English)

Asien-Pazifik

Kontakt zu Ihrer lokalen Niederlassung

How does interp1 work? (2024)
Top Articles
Latest Posts
Article information

Author: Chrissy Homenick

Last Updated:

Views: 5533

Rating: 4.3 / 5 (74 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: Chrissy Homenick

Birthday: 2001-10-22

Address: 611 Kuhn Oval, Feltonbury, NY 02783-3818

Phone: +96619177651654

Job: Mining Representative

Hobby: amateur radio, Sculling, Knife making, Gardening, Watching movies, Gunsmithing, Video gaming

Introduction: My name is Chrissy Homenick, I am a tender, funny, determined, tender, glorious, fancy, enthusiastic person who loves writing and wants to share my knowledge and understanding with you.