Project - Data Handling and Interpolation
Respected Sir,
Please verify the solutions of mini-project and give marks as i haven't submitted the mini-project earlier.
Mini project:-
Sol 3)
k = 5;
m = 3;
x0 = [2; 1];
dt = 0.1;
T = 20;
tspan = [0:dt:T];
A_matrix = [0 1; -k/m 0];
[t,x] = ode45(@(t,x) A_matrix*x, tspan, x0);
plot(t,x(:,1),'b', t,x(:,2),'r');
legend('vdot', 'xdot');
xlabel('Time t');
ylabel('Solution x');
grid;
vdot = (-k/m)*x(:,2);
hold on;
plot(t,vdot,'g--');
legend('vdot','xdot','xdot_dot');
Sol 4)
m file is attached along with plotation.
Sol 5)
m file is attached along with plot
PROJECT:- m-file,vi_modified.txt file & graphs are attached below
a = xlsread('VI.xlsx'); % reading data from excel file and storing into the varable 'a'
V = a(:,1); % reading data from excel file for all rows of column 1 and storing into variable 'V'
I = a(:,2); % reading data from excel file for all rows of column 1 and storing into variable 'I'
b = [-17.3:0.1:0.9]; % range given to calculate interpolation for 0.1 interval
vi = interp1(V,I,b,'spline'); % Spline interpolation is calculated for 1-D for smoothness
figure(1);
plot(V,I,b,vi,'r'); % plotation of spline interpolation default
grid;
hold;
title('Spline Interpolation [-17.3:0.1:0.9]');
xlabel('b');
ylabel('vi');
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]'; % modified range given to calculate interpolation
vi_modified = interp1(V,I,VV,'spline'); % Spline interpolation is calculated for 1-D for smoothness
figure(2);
plot(VV,vi_modified,'g'); % plotation of modified spline interpolation
grid;
xlabel('VV');
ylabel('vi-modified');
title('Spline Interpolation modified');
fileid = fopen('C:UsersASUSDocumentsMATLABvi_modified.txt','w'); % to write data in a text file
fprintf(fileid,'%0.4fn',vi_modified); % to print in a file in each new line
>> project
vi =
Columns 1 through 12
-28.0000 -28.1734 -24.0000 -19.0000 -15.8685 -14.0000 -12.2353 -10.5022 -9.0000 -7.8806 -7.1062 -6.5915
Columns 13 through 24
-6.2512 -6.0000 -5.7670 -5.5389 -5.3164 -5.1007 -4.8926 -4.6931 -4.5031 -4.3236 -4.1556 -4.0000
Columns 25 through 36
-3.8574 -3.7271 -3.6080 -3.4991 -3.3993 -3.3076 -3.2228 -3.1440 -3.0701 -3.0000 -2.9328 -2.8682
Columns 37 through 48
-2.8061 -2.7464 -2.6889 -2.6334 -2.5799 -2.5282 -2.4782 -2.4298 -2.3827 -2.3369 -2.2922 -2.2486
Columns 49 through 60
-2.2058 -2.1637 -2.1222 -2.0812 -2.0405 -2.0000 -1.9596 -1.9193 -1.8792 -1.8394 -1.7999 -1.7608
Columns 61 through 72
-1.7223 -1.6843 -1.6469 -1.6103 -1.5745 -1.5395 -1.5055 -1.4725 -1.4406 -1.4099 -1.3804 -1.3522
Columns 73 through 84
-1.3253 -1.3000 -1.2762 -1.2538 -1.2327 -1.2130 -1.1944 -1.1770 -1.1605 -1.1450 -1.1304 -1.1164
Columns 85 through 96
-1.1032 -1.0906 -1.0784 -1.0667 -1.0552 -1.0441 -1.0330 -1.0221 -1.0111 -1.0000 -0.9887 -0.9773
Columns 97 through 108
-0.9656 -0.9538 -0.9418 -0.9297 -0.9174 -0.9049 -0.8923 -0.8795 -0.8665 -0.8535 -0.8403 -0.8269
Columns 109 through 120
-0.8135 -0.7999 -0.7862 -0.7724 -0.7585 -0.7445 -0.7304 -0.7162 -0.7019 -0.6876 -0.6731 -0.6586
Columns 121 through 132
-0.6441 -0.6294 -0.6147 -0.6000 -0.5852 -0.5704 -0.5557 -0.5409 -0.5263 -0.5119 -0.4976 -0.4835
Columns 133 through 144
-0.4696 -0.4561 -0.4428 -0.4299 -0.4174 -0.4054 -0.3937 -0.3826 -0.3721 -0.3621 -0.3527 -0.3439
Columns 145 through 156
-0.3359 -0.3285 -0.3219 -0.3161 -0.3112 -0.3070 -0.3038 -0.3016 -0.3003 -0.3000 -0.3007 -0.3021
Columns 157 through 168
-0.3037 -0.3052 -0.3062 -0.3064 -0.3053 -0.3026 -0.2978 -0.2906 -0.2806 -0.2674 -0.2507 -0.2300
Columns 169 through 180
-0.2050 -0.1752 -0.1404 -0.1000 -0.0559 -0.0182 0.0007 -0.0002 0.0002 0.0129 0.1700 1.2300
Columns 181 through 183
10.0433 39.0701 101.1102
Current plot released
vi_modified =
-28.1734
-24.0000
-2.8682
-2.6889
-2.4298
-2.2058
-1.6103
-1.1164
-0.7105
-0.7445
-0.2906
0.0012
-0.0001
0.1700
1.5665