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

7 次查看(过去 30 天)
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')

采纳的回答

Voss
Voss 2023-9-25
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')

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Circuits and Systems 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by