Azzera filtri
Azzera filtri

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

7 visualizzazioni (ultimi 30 giorni)
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')

Risposta accettata

Voss
Voss il 25 Set 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')

Più risposte (0)

Categorie

Scopri di più su Circuits and Systems 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