Challenge

Project - Data Handling and Interpolation

Script

% Project Data Handling and Interpolation
%Clearing the open files,workspace variables and command window
close all
clear all
clc
<!-- [if mso]>
<![endif]-->
%Reading the 'VI.xlsx' Excle file and storing it in a variable 'data'
data=xlsread('VI.xlsx');
<!-- [if mso]>
<![endif]-->
% Storing read each column data in to seperate variables
Voltage=data(:,1);
Current=data(:,2);
<!-- [if mso]>
<![endif]-->
�fining the interpolation range from the given data
V_intp=-17.3:0.1:0.9;
<!-- [if mso]>
<![endif]-->
%Interpolating Current data w.r.t given Volatge range
C_intp=interp1(Voltage,Current,V_intp,'spline');
<!-- [if mso]>
<![endif]-->
%Plotting(Naming the plot, naming axes etc.
figure(1);
plot(Voltage,Current,'g','LineWidth',2);
axis([-30 10 -30 10]);
legend('Recorded Values','Location','southeast')
title('Original Plot');
xlabel('Voltage(V)');
ylabel('Current(mA)');
grid on
<!-- [if mso]>
<![endif]-->
%Ploting the intetrpolated data, and labelling etc.
figure(2)
plot(V_intp,C_intp,'m:','LineWidth',2.5);
axis([-30 10 -30 10]); %axis limitation
title('Interpolated Plot');
xlabel('Voltage(V)');
ylabel('Current(mA)');
legend('Interolated Graph','Location','southeast');
grid on
<!-- [if mso]>
<![endif]-->
%Ploting the intetrpolated data and Experimental data,in same figure(3)
figure(3)
plot(Voltage,Current,'o');
hold on
plot(V_intp,C_intp,'r-');
grid on
title('Exp v/s Interpolation');
xlabel('Voltage(V)');
ylabel('Current(mA)');
legend('Experimental','Interpolated');
grid on
<!-- [if mso]>
<![endif]-->
%Saving the data to  text file
%Opening file id
fid=fopen('Interpolated Curent and Voltage.txt','w');
<!-- [if mso]>
<![endif]-->
%Printing the the Headers in first row of file
fprintf(fid,'Volt(V) Current(mA)\n');
<!-- [if mso]>
<![endif]-->
%Printing the individual Voltage and curent values one by one using forloop
for i=1:length(V_intp)
fprintf(fid,'%f %f\n',V_intp(i),C_intp(i));
end
%closing file pointer
fclose(fid);
 
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.