Challenge

Project - Data Handling and Interpolation

Project:

From the laboratory experiment, data on voltage and current has been recorded. The same data is accessed in an excel file.

Read the excel file

Laboratory experimental data for voltage vs current values available in an excel file has been accessed by using the Matlab command ‘xlsread’. Matlab code is also provided below.

---------------------------------------------------------------------------------------------------------------------------

%% Read the excel file
[exp_data1]=xlsread('VI.xlsx',1,'A2:B25'); % voltage vs current data excel read
V = exp_data1(:,1); % defining altitude values to voltage(V) in Volts
I = exp_data1(:,2); % defining altitude values to current(I) in mAmps

---------------------------------------------------------------------------------------------------------------------------

Interpolation in the range of -17.3:0.1:0.9

Using the syntax of interpolation to the given range with the ‘spline’ method. And plotted for the interpolated using the ‘plot’ command. Matlab code is also provided below.

---------------------------------------------------------------------------------------------------------------------------

%% interpolation in the range of -17.3:0.1:0.9
t = -17.3:0.1:0.9; % range of interpolation
y = interp1(V,I, t, 'spline'); % interpolation syntax with spline method
plot(t,y,'-k'); % plot the interpolated values
legend('exp. data','interpolated data') %legend assigned to the output plot

---------------------------------------------------------------------------------------------------------------------------

Store them in a text file

Finally, all the obtained interpolated values are stored in a text file. Using the ‘fopen’ command in Matlab and the code for the same is also provided below.

---------------------------------------------------------------------------------------------------------------------------

%% store the interpolated values in text file
filename=fopen('Updated_data.txt','w'); % store the missing values in the filename
fprintf(filename,'%d \t', y);
fclose(filename);

---------------------------------------------------------------------------------------------------------------------------

The below image shows the script file for obtaining the interpolation values for the given range and storing the values in a text file. All the executed files are shown in the workspace in Matlab GUI.

---------------------------------------------------------------------------------------------------------------------------

Output:

The plot for the raw experimental data and interpolated data has shown in the figure attached below.

Stored interpolated values in the file name as specified in the code. Values has been stored or written in the file as shown in the figure below.

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.