Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8420921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:59:40+00:00 2026-06-10T02:59:40+00:00

Imagine a set of data with given x-values (as a column vector) and several

  • 0

Imagine a set of data with given x-values (as a column vector) and several y-values combined in a matrix (row vector of column vectors). Some of the values in the matrix are not available:

%% Create the test data
N = 1e2; % Number of x-values

x = 2*sort(rand(N, 1))-1;
Y = [x.^2, x.^3, x.^4, x.^5, x.^6]; % Example values
Y(50:80, 4) = NaN(31, 1); % Some values are not avaiable

Now i have a column vector of new x-values for interpolation.

K = 1e2; % Number of interplolation values
x_i = rand(K, 1);

My goal is to find a fast way to interpolate all y-values for the given x_i values. If there are NaN values in the y-values, I want to use the y-value which is before the missing data. In the example case this would be the data in Y(49, :).

If I use interp1, I get NaN-values and the execution is slow for large x and x_i:

starttime = cputime;
Y_i1 = interp1(x, Y, x_i);
executiontime1 = cputime - starttime

An alternative is interp1q, which is about two times faster.

What is a very fast way which allows my modifications?

Possible ideas:

  1. Do postprocessing of Y_i1 to eliminate NaN-values.
  2. Use a combination of a loop and the find-command to always use the neighbour without interpolation.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T02:59:42+00:00Added an answer on June 10, 2026 at 2:59 am

    Using interp1 with spline interpolation (spline) ignores NaN’s.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given a data set of various currency pairs, how do I efficiently compute the
Imagine each row as X axis and each column as a series (a line
Imagine I've got a database with lots of data, from which users can search.
Imagine a very big gwt project of application. This is just a some form
Imagine you are simulating particle physics. You, then, have a position vector for each
I have a set of data on which I need to perform a topological
We're building a GIS interface to display GPS track data, e.g. imagine the raw
I have created a script that analyzes a set of raw data and converts
Imagine that you have a large set of #m objects with properties A and
Imagine we have a set of entities each of which has its state: free,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.