Project - Data Handling and Interpolation
VI =
-17.3000 -28.0000
-17.1000 -24.0000
-17.0000 -19.0000
-16.8000 -14.0000
-16.5000 -9.0000
-16.0000 -6.0000
-15.0000 -4.0000
-14.0000 -3.0000
-12.0000 -2.0000
-10.0000 -1.3000
-8.0000 -1.0000
-5.0000 -0.6000
-2.0000 -0.3000
-0.2000 -0.1000
0.0900 0
0.1900 0
0.2700 0
0.3900 0.0100
0.4300 0.0300
0.5000 0.1700
0.5500 0.4200
0.6000 1.2300
0.6200 1.9900
0.6500 3.9100
Data Given
>> VV=[-17.2 -17.1 -13.8 -13.5 -13.0 -12.5 -11 -9 -5.76 -6 -1 0.11 0.25 0.5 0.61]
VV =
Columns 1 through 5
-17.2000 -17.1000 -13.8000 -13.5000 -13.0000
Columns 6 through 10
-12.5000 -11.0000 -9.0000 -5.7600 -6.0000
Columns 11 through 15
-1.0000 0.1100 0.2500 0.5000 0.6100
>> legend('VI data','VI interpolated data');
Applying Spline Interpolation
>> yq2=interp1(Voltage,Amps,VV,'spline');
Plotting Given Data (VV) vs Interpolated Data graph and applying values
>> figure(4);plot(VV,yq2,'*',range,yq1);grid;
>> title('VV vs VI');
>> ylabel('I(mAmps)');
>> xlabel('V(volt)');
>> title('Given Data VV vs Interpolated Data');
>> legend('Given data','Interpolated data');
Saving figure4 as pdf
>> print('Given Data VV vs Interpolated Data','-dpdf');
Savng the values into a text file
File opening
>> fid=fopen('VI.txt','w');
Giving Headings as Volt and Amps
>> fprintf(fid,'V(Volt) I(Amps)\n');
>> len=length(VV);
\n for next line,%f is used instead of %d to get decimal values
>> for i=1:len, fprintf(fid,'%f %f\n',VV(i),yq2(i));
end;
File closing
>> fclose(fid);
Given VV is denoted as Volt
V(Volt) I(Amps)
-17.20000 -28.173426
-17.10000 -24.000000
-13.80000 -2.868222
-13.50000 -2.688869
-13.00000 -2.429766
-12.50000 -2.205780
-11.00000 -1.610323
-9.000000 -1.116443
-5.760000 -0.710517
-6.000000 -0.744512
-1.000000 -0.290596
0.110000 0.001150
0.250000 -0.000137
0.500000 0.170000
0.610000 1.566533