Challenge

Project - Data Handling and Interpolation

% PROJECT-
% Read the excel file in the Matlab program and perform the interpolation in the range of -17.3:0.1:0.9.
% Generate the interactive plot for the interpolated data and store them in a text file.

clc;clear all; close all;
% interpolation of voltage and current data
Z=xlsread('VI.xlsx');% reading excel file data
v=Z(:,1); % voltage data seperating
i=Z(:,2) ; % current data seperating
xq=[-17.3:0.1:0.9]; % interpolation range specified
yq1=interp1(v,i,xq); % linear interpolation
yq2=interp1(v,i,xq,'spline'); % spline interpolation
% Linear interpolation plotting
figure(1)
plot(v,i,'o',xq,yq1,': .');
title('Linear Interpolation');
xlabel('Voltage (V)');
ylabel('Current (I)');
legend('Actual Value', 'Interpolated value', 'location','Northeast');
grid on;
% spline interpolation plotting
figure(2)
plot(v,i,'o',xq,yq2,'b: .');
title('SPLINE INTERPOLATION');
xlabel('Voltage (V)');
ylabel('Current (I)');
legend('Actual Value', 'Interpolated value', 'location','Northeast');
grid on;
% saving the interpolation data into text file
%opening text file
interpolation_data=fopen('VI_output.txt','w');
fprintf(interpolation_data,' Voltage Current\n');
fprintf(interpolation_data,'%4.3f %5.3f\n',xq,yq2); %writing voltage & current value
savefig(1,'vilinear.fig'); %saving linear interpolation graph
savefig(2,'vispline.fig'); %saving spline interpolation graph
fclose(interpolation_data);

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.