Challenge

Project - Data Handling and Interpolation

clc

clear

close all

%% reading data from excel

Fileid = xlsread('VI.xlxs');

V = FileId(:,1);

I= FileId(:,2);

%% interpolation linear

Vq = -17.3;0.1;0.9;

Iq = interp1 (V,I,Vq);

%% spline method Iq2

Iq2 = interp1 (V,I, Vq, 'spline');

%% computing current (Iq3) for the given VV voltage data

VV = [-17.3,-17.1,-17,-16.8,-16.5,-16,-15,-14,-12,-10,-8,-5,-2,-0.2,0.09,0.19,0.27,0.39,0.43,0.5,0.55,0.6,0.62,0.65]

Iq3 = interp1(V,I,VV);

%% plotted the V Vs I

subplot(2,2,1);

plot(V,I,'o','Linewidth',2);

grid on

axis([-18 2 -30 5])

xlabel('voltage V Volt');

ylabel('Current I Ampere');

title('V vs I data')

subplot(2,2,2);

plot(V,I,'o',Vq,Iq,'r' , 'Linewidth' ,2);

grid on

axis([-18 2 -30 5])

xlabel('voltage V Volt');

ylabel('Current I Ampere');

title('V vs I Linear Interpolation')

subplot(2,2,3);

plot(V,I,'0',Vq,Iq2,'g','LineWidth',2);

grid on

axis([-18 2 -30 5])

xlabel('voltage V Volt');

ylabel('Current I Ampere');

title('V vs I Spline Interpolation')

%% compute the current from the given voltage data and store it in the text file

f = fopen('voltageCurrentdata.txt','w',);

fprintf(f,'computing the Current from given voltage data\n');

fprintf(f,'Voltage\t Current \n');

for i=1: length(VV)

fprintf(f,'%.4f \t %0.4f\n',VV(i),Iq3(i));

end

fclose(f);

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.