Looking for the MatLab code written out using the text files as if you had them.
ID: 3777347 • Letter: L
Question
Looking for the MatLab code written out using the text files as if you had them. The names of the text files are exactly as shown in the question. Also, each text file has 4 columns of data. NEED CODE ASAP! Please!
i. Consider the 3 text files labeled "aluminum-test", 5-MIL-test" and "2-MIL-test" that are uploaded and attached to the assignment link.This data was collected when running Arizona State University's shocktube during an AEE 362 (High Speed Aerodynamics) laboratory experiment. The tests show data for 3 different shock wave experiments where shocks of different strengths were intentionally generated. Note that the first two columns represent pressure data (reported in psi) and that columns 3 and 4 show pressure data in units of Volts. Therefore, the data in columns 3 and 4 must be converted to useful units before it can be plotted. The conversion is given below. giving you a result in PSI. PSI 0.0418 mV Your task is to: a. Load this data into MATLAB (hint load0 you may also need to remove the textat the top of the data file) b. Find the total time of the dataset, noting that the time between data points is 0.025 ms c. Add 14.0 to all the values in the second column. Plot this data together with that of the first column vs. time. Knowing that this is pressure, what appears to be happening? d. Plot the data in columns 3 and 4 ws. time, after this data has been converted to PSI. These sensors were mounted inside the tube and represent changes in pressure over time. What can you see from the data? (quick comment) e. The distance between the two pressure transducers is given as 48-s n. Knowing this, we can use the "peaks from the data in the plot from (d) (showing two changes in pressure at two different locations) to calculate the speed of the resulting shockwave. After generating the plot, use the "cursor tool" and find the 4t between the two peaks u may also need to zoom in considering it is the first two peaks weareinterested in). The velocity ofthe wave can then be calculated using: At where 4x is the distance between pressure sensors. Compare shock speeds between the materials (no comments/analysis needed but look at the results!) The material strength are in the order: 5 Mil, 2Mil, Aluminum.Explanation / Answer
Note: e part not implemented.
Code:
%first file
%read the file
fileid=fopen('aluminium_test.txt')
%remove the first line
line=fgetl(fileid);
%read rest of data
C=fscanf(fileid,'%f');
i=2;
%find total time
total_time=0.025*(numel(C)-1);
%increment secon col by 14
while(i<=numel(C))
C(i)=C(i)+14;
i=i+4;
end
%save first coloumn values to a vector
i=1
k=1
while(i<=numel(C))
first(k)=C(i);
i=i+4;
k=k+1;
end
%save second coloumn values to a vector
i=2
k=1
while(i<=numel(C))
second(k)=C(i);
i=i+4;
k=k+1;
end
% chnage third col and fourt col to PSI
% 1V=23923.44 PSI
i=3
while(i<=numel(C))
C(i)=C(i)*23923.44;
C(i+1)=C(i+1)*23923.44;
i=i+4;
end
%save third coloumn values to a vector
i=3
k=1
while(i<=numel(C))
third(k)=C(i);
i=i+4;
k=k+1;
end
%save fourth coloumn values to a vector
i=4
k=1
while(i<=numel(C))
fourth(k)=C(i);
i=i+4;
k=k+1;
end
%plot
t=0:0.025:0,125
plot(t,first,t,second)
plot(t,third,t,fourth)
% second file
%read the file
fileid=fopen('5_MIL_test.txt')
%remove the first line
line=fgetl(fileid);
%read rest of data
C=fscanf(fileid,'%f');
i=2;
%find total time
total_time=0.025*(numel(C)-1);
%increment secon col by 14
while(i<=numel(C))
C(i)=C(i)+14;
i=i+4;
end
%save first coloumn values to a vector
i=1
k=1
while(i<=numel(C))
first(k)=C(i);
i=i+4;
k=k+1;
end
%save second coloumn values to a vector
i=2
k=1
while(i<=numel(C))
second(k)=C(i);
i=i+4;
k=k+1;
end
% chnage third col and fourt col to PSI
% 1V=23923.44 PSI
i=3
while(i<=numel(C))
C(i)=C(i)*23923.44;
C(i+1)=C(i+1)*23923.44;
i=i+4;
end
%save third coloumn values to a vector
i=3
k=1
while(i<=numel(C))
third(k)=C(i);
i=i+4;
k=k+1;
end
%save fourth coloumn values to a vector
i=4
k=1
while(i<=numel(C))
fourth(k)=C(i);
i=i+4;
k=k+1;
end
%plot
t=0:0.025:0,125
plot(t,first,t,second)
plot(t,third,t,fourth)
% third file
%read the file
fileid=fopen('2_MIL_test.txt')
%remove the first line
line=fgetl(fileid);
%read rest of data
C=fscanf(fileid,'%f');
i=2;
%find total time
total_time=0.025*(numel(C)-1);
%increment secon col by 14
while(i<=numel(C))
C(i)=C(i)+14;
i=i+4;
end
%save first coloumn values to a vector
i=1
k=1
while(i<=numel(C))
first(k)=C(i);
i=i+4;
k=k+1;
end
%save second coloumn values to a vector
i=2
k=1
while(i<=numel(C))
second(k)=C(i);
i=i+4;
k=k+1;
end
% chnage third col and fourt col to PSI
% 1V=23923.44 PSI
i=3
while(i<=numel(C))
C(i)=C(i)*23923.44;
C(i+1)=C(i+1)*23923.44;
i=i+4;
end
%save third coloumn values to a vector
i=3
k=1
while(i<=numel(C))
third(k)=C(i);
i=i+4;
k=k+1;
end
%save fourth coloumn values to a vector
i=4
k=1
while(i<=numel(C))
fourth(k)=C(i);
i=i+4;
k=k+1;
end
%plot
t=0:0.025:0,125
plot(t,first,t,second)
plot(t,third,t,fourth)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.