Help me to fill the gap of the data points using linear interpolation.
6 次查看(过去 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')
0 个评论
采纳的回答
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')
2 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!