Challenge

Project - Data Handling and Interpolation

CODE:

f = xlsread('VI.xlsx'); %Reading the xlsx file

V = f(:,1); %storing first column value of 'f' in 'V'
I = f(:,2); %storing second column value of 'f' in 'A'

Vinp = -17.3:0.1:0.9; % Creating Given Range of Voltage Data mentioned in problem
Iinp = interp1(V,I,Vinp,"spline"); % Using 'interp1' function for calculating Current value for given %Voltage Range 'Vinp'

figure(1);
subplot(1,2,1)
plot(V,I,'-o');grid; % Ploting trig_function with time
title('Given Data'); %giving title for the figure
ylabel('I(mAmp)');

xlabel('V(Volt)'); %giving lables to both the axis
axis([-20 5 -30 5]); %Defining axis limits

subplot(1,2,2)
plot(Vinp,Iinp);grid; % Ploting trig_function with time
title('Calculated By Interpolation Data'); %giving title for the figure
ylabel('I(mAmp)');

xlabel('V(Volt)'); %giving lables to both the axis
axis([-20 5 -30 5]); %Defining axis limits

figure(2);
plot(V,I,'o',Vinp,Iinp,'--');

grid; %ploting the values
title('Volteg(V) vs Current(I) Validation plot'); %giving title for the figure
xlabel('V(Volt)');ylabel('I(mAmp)'); %labeling X and Y axis
legend('Given Data','Calculated by Interpolation','Location','best'); % Showing legends

fid = fopen('Volt_and_Current.txt','w'); % opening output file
fprintf(fid,'V(Volt) I(mAmp)\n'); % storing value of variable x in file
for i = 1:length(V)
fprintf(fid,'%.3f %.3f\n',V(i),Iinp(i)); % storing value of variable x in file
end
fclose(fid); % closing output file

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.