Add interpolated data at a specific location in the main array.

1 visualizzazione (ultimi 30 giorni)
Harjot Singh Saluja il 21 Nov 2020
Risposto: Andrei Bobrov il 21 Nov 2020
Hello,
I am working with an array which has a size of 603x1. However, there is data that is missing at two locations in the array. I have used the interp1 function to determine missing data and have it stored in a matrix. The location where the data is missing has 25 and 14 interpolated points respectively. I want to add the interpolated data into the main array at the specific locations, which are between the elements 28 and 29, and 186 and 187 respectively, such that the new array has a size of 642x1. I have attached the two variables with this question for reference. How can this be done?
Kind regards,
Harjot
0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

Risposte (2)

KALYAN ACHARJYA il 21 Nov 2020
Modificato: KALYAN ACHARJYA il 21 Nov 2020
This way?
array_new=[array_data(1:28),int_data,array_data(29:end)]
1 CommentoMostra -1 commenti meno recentiNascondi -1 commenti meno recenti
Harjot Singh Saluja il 21 Nov 2020
This will work. But how can I make it a general purpose thing? For example, instead of two locations, what if there is missing data for three/four locations?

Accedi per commentare.

Andrei Bobrov il 21 Nov 2020
a =tlv_lis_alt;
input = interpol_alt;
idx = [29;187];
k = numel(a);
b = ones(k,1);
[m,n] = size(input);
lo = ~isnan(input);
ct = sum(lo);
b(idx) = ct + 1;
out = nan(sum([k;ct(:)]),1);
out(cumsum(b)) = a;
out(isnan(out)) = input(lo);
0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

Categorie

Scopri di più su Interpolation in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by