Effacer les filtres
Effacer les filtres

Help me to fill the gap of the data points using linear interpolation.

7 vues (au cours des 30 derniers jours)
NANDEESWARAN
NANDEESWARAN le 25 Sep 2023
Modifié(e) : Voss le 25 Sep 2023
clear,clc,close all
fname = 'RLC_Step_Underdamped_b.csv';
Data = importdata(fname,',',15);
Fs = 25000;
time = Data.data(:,1)/Fs;
voltage = Data.data(:,3);
time_copy = time;
voltage_copy = voltage;
gap = find(isnan(voltage_copy));
gap_time = time(gap);
time_copy = [];
voltage_copy = [];
gap_voltage_linear = interp1(time_copy,voltage_copy,gap_time,'linear')
plot(time,voltage,'k',gap_time,gap_voltage_linear,'r',gap_time,gap_voltage_spline,'b','LineWidth',2)
xlabel('time(s)')
ylabel('Voltage(V)')
title('Step response of an underdamped RLC Circuit')
legend('Original dat with gaps','Linear Interpolation','Spline interpolation')

Réponse acceptée

Voss
Voss le 25 Sep 2023
clear,clc,close all
fname = 'RLC_Step_Underdamped_b.csv';
Data = importdata(fname,',',15);
Fs = 25000;
time = Data.data(:,1)/Fs;
voltage = Data.data(:,3);
voltage_linear = fillmissing(voltage,'linear');
voltage_spline = fillmissing(voltage,'spline');
plot(time,voltage,'k',time,voltage_linear,'--r',time,voltage_spline,'--b','LineWidth',2)
xlabel('time(s)')
ylabel('Voltage(V)')
title('Step response of an underdamped RLC Circuit')
legend('Original dat with gaps','Linear Interpolation','Spline interpolation')
  2 commentaires
NANDEESWARAN
NANDEESWARAN le 25 Sep 2023
Thank you so much sir.
Voss
Voss le 25 Sep 2023
Modifié(e) : Voss le 25 Sep 2023
You're welcome! Any questions, let me know.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Circuits and Systems dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by