interp1() returns a plot with empty sections

I am trying to use the interp1() function to first, plot a continuous graph between a variable and time. Then I want to use the plot to look up the value of the variable at every instant. However, my plot appears to have empty sections, which is probably why I get NaN errors in my calculations. I attached my excel file also.
grade_data = readmatrix(‘grade.xlsx’); % reads the excel file

t_grade_raw = grade_data(:, 1)’; % Extract Time (transpose to row vector)
grade_raw = grade_data(:, 2)’; % Extract Grade (transpose to row vector)

% Interpolating to plot
grade_interp = interp1(t_grade_raw, grade_raw, t, ‘linear’);

% Safety: Replace any remaining NaNs with 0
grade_interp(isnan(grade_interp)) = 0;

% Graphing
plot(t, grade_interp, ‘r-‘, ‘LineWidth’, 1.5);I am trying to use the interp1() function to first, plot a continuous graph between a variable and time. Then I want to use the plot to look up the value of the variable at every instant. However, my plot appears to have empty sections, which is probably why I get NaN errors in my calculations. I attached my excel file also.
grade_data = readmatrix(‘grade.xlsx’); % reads the excel file

t_grade_raw = grade_data(:, 1)’; % Extract Time (transpose to row vector)
grade_raw = grade_data(:, 2)’; % Extract Grade (transpose to row vector)

% Interpolating to plot
grade_interp = interp1(t_grade_raw, grade_raw, t, ‘linear’);

% Safety: Replace any remaining NaNs with 0
grade_interp(isnan(grade_interp)) = 0;

% Graphing
plot(t, grade_interp, ‘r-‘, ‘LineWidth’, 1.5); I am trying to use the interp1() function to first, plot a continuous graph between a variable and time. Then I want to use the plot to look up the value of the variable at every instant. However, my plot appears to have empty sections, which is probably why I get NaN errors in my calculations. I attached my excel file also.
grade_data = readmatrix(‘grade.xlsx’); % reads the excel file

t_grade_raw = grade_data(:, 1)’; % Extract Time (transpose to row vector)
grade_raw = grade_data(:, 2)’; % Extract Grade (transpose to row vector)

% Interpolating to plot
grade_interp = interp1(t_grade_raw, grade_raw, t, ‘linear’);

% Safety: Replace any remaining NaNs with 0
grade_interp(isnan(grade_interp)) = 0;

% Graphing
plot(t, grade_interp, ‘r-‘, ‘LineWidth’, 1.5); interpolation MATLAB Answers — New Questions

​

Leave a Reply

Your email address will not be published. Required fields are marked *