Challenge

Project - Data Handling and Interpolation

% hence we know the relation between voltage and current
% thats why its so easy to intpret it as we would get straight line
% implies we would use reverse bias current in diode in which there is
% negative voltage

vi = xlsread('VI.xlsx'); % load the exel data (VI.xlsx) file in
v = vi(:,1); % we have both current and voltage in same file hence
i = vi(:,2); % we use the commmand vi(:,1) for column 1 which is voltage
v1 = [-17.3:0.1:0.9]; % set the range for interpolation
i1 = interp1(v,i,v1,'spline'); % first doin spline interpolation
i2 = interp1(v,i,v1); % second is default interpolation
figure(1);
plot(v,i,'o',v1,i1);grid;
title('spline interpolation');
figure(2);
plot(v,i,'o',v1,i2);grid;
title('default interpolation')
v2 = [-17.30:0.01:0.90]; % we had range of .1 but in question we have to get value for upto two decimal value voltage
i3 = interp1(v,i,v2,'spline');
figure(3);
plot(v2,i3);grid;
title('finding values of current using plot');

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];
vd = [-17.2 -17.1 -13.8 -13.5 -13.0 -12.5 -11 -9 -5.76 -6 -1 0.00 0.25 0.5 0.70];
index = [];
index1 = [];


% now we have to allot index of element which matches the element of vd or
% vv hence we make a loop
a =1;
while a<16
for j = 1:1821
if v2(j) == VV(a)
index = [index j];
end
end
a = a+1;
end
c = length(index);
y = [];

for k = 1:c
b = index(k);
y = [y i3(b)];
end
save('current_eg1.mat','y');

% lets take another example with different values of voltage
% by applting same steps
p =1;
while p<16
for m = 1:1821
if v2(m) == vd(p)
index1 = [index1 m];
end
end
p = p+1;
end
d = length(index1);
y1 = [];

for n = 1:d
e = index1(n);
y1 = [y1 i3(e)];
end
save('current_eg2.mat','y1');
fid = fopen('current1.txt','w');
len = length(y);
for i = 1:len,
fprintf(fid,'%d',y(i));
end; fclose(fid);

% save txt for second example
fid1 = fopen('current2.txt','w');
leng = length(y1);
for i = 1:leng,

fprintf(fid1,'%d',y1(i));
end; fclose(fid1);


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.