Challenge

Project - Data Handling and Interpolation

Soultion :

Interpolation:

Input:

A = xlsread('VI.xlsx');
V = A(:,1);
I = A(:,2);
plot(V,I);
hold on;
B = -17.3:0.1:0.9;
x1 = interp1(V,I,B,'spline');
plot(V,I,'m',B,x1,"o");
grid on;
title('spline interpolation');
xlabel('current');
ylabel('Voltage');
VV = -17.2:0.1:0.61;
x2 = interp1(V,I,VV);
x3 = [VV x2];
fid = fopen('text.txt','w');
fprintf(fid,'%6s %12s\n','VV','x2');
fprintf(fid,'%6.2f %12.8f\n',x3);
fclose(fid);

Output:

Text format file:

VV x2
-17.20 -17.10000000
-17.00 -16.90000000
-16.80 -16.70000000
-16.60 -16.50000000
-16.40 -16.30000000
-16.20 -16.10000000
-16.00 -15.90000000
-15.80 -15.70000000
-15.60 -15.50000000
-15.40 -15.30000000
-15.20 -15.10000000
-15.00 -14.90000000
-14.80 -14.70000000
-14.60 -14.50000000
-14.40 -14.30000000
-14.20 -14.10000000
-14.00 -13.90000000
-13.80 -13.70000000
-13.60 -13.50000000
-13.40 -13.30000000
-13.20 -13.10000000
-13.00 -12.90000000
-12.80 -12.70000000
-12.60 -12.50000000
-12.40 -12.30000000
-12.20 -12.10000000
-12.00 -11.90000000
-11.80 -11.70000000
-11.60 -11.50000000
-11.40 -11.30000000
-11.20 -11.10000000
-11.00 -10.90000000
-10.80 -10.70000000
-10.60 -10.50000000
-10.40 -10.30000000
-10.20 -10.10000000
-10.00 -9.90000000
-9.80 -9.70000000
-9.60 -9.50000000
-9.40 -9.30000000
-9.20 -9.10000000
-9.00 -8.90000000
-8.80 -8.70000000
-8.60 -8.50000000
-8.40 -8.30000000
-8.20 -8.10000000
-8.00 -7.90000000
-7.80 -7.70000000
-7.60 -7.50000000
-7.40 -7.30000000
-7.20 -7.10000000
-7.00 -6.90000000
-6.80 -6.70000000
-6.60 -6.50000000
-6.40 -6.30000000
-6.20 -6.10000000
-6.00 -5.90000000
-5.80 -5.70000000
-5.60 -5.50000000
-5.40 -5.30000000
-5.20 -5.10000000
-5.00 -4.90000000
-4.80 -4.70000000
-4.60 -4.50000000
-4.40 -4.30000000
-4.20 -4.10000000
-4.00 -3.90000000
-3.80 -3.70000000
-3.60 -3.50000000
-3.40 -3.30000000
-3.20 -3.10000000
-3.00 -2.90000000
-2.80 -2.70000000
-2.60 -2.50000000
-2.40 -2.30000000
-2.20 -2.10000000
-2.00 -1.90000000
-1.80 -1.70000000
-1.60 -1.50000000
-1.40 -1.30000000
-1.20 -1.10000000
-1.00 -0.90000000
-0.80 -0.70000000
-0.60 -0.50000000
-0.40 -0.30000000
-0.20 -0.10000000
0.00 0.10000000
0.20 0.30000000
0.40 0.50000000
0.60 -26.00000000
-24.00 -19.00000000
-16.50 -14.00000000
-12.33 -10.66666667
-9.00 -8.40000000
-7.80 -7.20000000
-6.60 -6.00000000
-5.80 -5.60000000
-5.40 -5.20000000
-5.00 -4.80000000
-4.60 -4.40000000
-4.20 -4.00000000
-3.90 -3.80000000
-3.70 -3.60000000
-3.50 -3.40000000
-3.30 -3.20000000
-3.10 -3.00000000
-2.95 -2.90000000
-2.85 -2.80000000
-2.75 -2.70000000
-2.65 -2.60000000
-2.55 -2.50000000
-2.45 -2.40000000
-2.35 -2.30000000
-2.25 -2.20000000
-2.15 -2.10000000
-2.05 -2.00000000
-1.96 -1.93000000
-1.89 -1.86000000
-1.82 -1.79000000
-1.75 -1.72000000
-1.68 -1.65000000
-1.61 -1.58000000
-1.54 -1.51000000
-1.48 -1.44000000
-1.40 -1.37000000
-1.33 -1.30000000
-1.28 -1.27000000
-1.25 -1.24000000
-1.23 -1.21000000
-1.19 -1.18000000
-1.17 -1.15000000
-1.13 -1.12000000
-1.10 -1.09000000
-1.07 -1.06000000
-1.04 -1.03000000
-1.01 -1.00000000
-0.99 -0.97333333
-0.96 -0.94666667
-0.93 -0.92000000
-0.91 -0.89333333
-0.88 -0.86666667
-0.85 -0.84000000
-0.83 -0.81333333
-0.80 -0.78666667
-0.77 -0.76000000
-0.75 -0.73333333
-0.72 -0.70666667
-0.69 -0.68000000
-0.67 -0.65333333
-0.64 -0.62666667
-0.61 -0.60000000
-0.59 -0.58000000
-0.57 -0.56000000
-0.55 -0.54000000
-0.53 -0.52000000
-0.51 -0.50000000
-0.49 -0.48000000
-0.47 -0.46000000
-0.45 -0.44000000
-0.43 -0.42000000
-0.41 -0.40000000
-0.39 -0.38000000
-0.37 -0.36000000
-0.35 -0.34000000
-0.33 -0.32000000
-0.31 -0.30000000
-0.29 -0.27777778
-0.27 -0.25555556
-0.24 -0.23333333
-0.22 -0.21111111
-0.20 -0.18888889
-0.18 -0.16666667
-0.16 -0.14444444
-0.13 -0.12222222
-0.11 -0.10000000
-0.07 -0.03103448
0.00 0.00000000
0.00 0.01500000
0.17 1.23000000
Output:

interpolation_function

ans = 0

Graph (spline interpolation):

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.