The data is organized in the following form: where column one is the flow rate d
ID: 2074133 • Letter: T
Question
The data is organized in the following form: where column one is the flow rate data from the first test, column two is the pressure from the first test, column three is the flow data from the second test, column four is the pressure data from the second test, column five is the flow data from the third test and the last column is the pressure data from the third test. You are then asked to use MATLAB to make a graph and determine the trend-lines for the data. (Pressure has units of MP a and volumetric flow of m3/s).
1)Graph the three different results for each test in on single figure using the MATLAB subplot() function. Each subplot should be a pressure vs. volumetric flow graph for each test. The subplot for the first test should have red circles as markers and should be located at the top left of the overall plot, the second subplot for the second test should use blue circles as markers and should be located at the top right of the overall plot, and the third subplot for the third test should use green circle markers and be located at the bottom of the overall plot. Label the axes and the titles of each of the subplots and the overall plot. Do not forget to include units. This should be figure 1.
2)Graph all of the tests on one plot, with Test I’s point markers being green x’s, Test II’s point markers being red circles, and Test III’s point markers being blue crosses. Use the polyfit() and polyval() functions in order to find the best second degree fit curve for the data of each test. The best fit lines must be of the same colors of the markers that correspond to each test and must be a line. That is, the the best fit line for Test I must be a green line. Plot the fitted curves for each test on the same graph. Make a legend in the top-left corner of the plot, labeling the data points and the fitted curves on it. Do not forget to label your axis and title your graph ”Compressor Performance”. Include units in your graph. This should be figure 2 and it should only be one plot; do not use subplots. Suppress your variables and answers for this part.
0.8
9998 3 6862 2.66 2123 2.1 10324 2.98 7251 2.6 2765 2 11000 2.9 7854 2.5 3756 1.8 11524 2.8 9234 2.25 5442 1.4 13126 2.42 9984 2.05 6021 1.2 13954 2.1 10862 1.8 6452 1.05 15000 1.5 11865 1.33 69780.8
Explanation / Answer
The MATLAB code is given below, just run it you will get all the plots required. I have used 2nd order polynomial fit for all the 3 test's data.
-----------------------------------
clear all; clc; close all;
data=[9998, 3, 6862, 2.66, 2123, 2.1;
10324, 2.98, 7251, 2.6, 2765, 2;
11000, 2.9, 7854, 2.5, 3756, 1.8;
11524, 2.8, 9234, 2.25, 5442, 1.4;
13126, 2.42, 9984, 2.05, 6021, 1.2;
13954, 2.1, 10862, 1.8, 6452, 1.05;
15000, 1.5, 11865, 1.33, 6978, 0.8];
C1=data(:,1:2); % test 1
C2=data(:,3:4); % test 2
C3=data(:,5:6); % test 3
figure(1)
subplot(2,2,1)
plot(C1(:,1),C1(:,2),'ro');ylabel('Pressure[MPa]');xlabel('Volumetric flow [m^3/s]');title('Test I')
subplot(2,2,2)
plot(C2(:,1),C2(:,2),'bo');ylabel('Pressure[MPa]');xlabel('Volumetric flow [m^3/s]');title('Test II')
subplot(2,1,2)
plot(C3(:,1),C3(:,2),'go');ylabel('Pressure[MPa]');xlabel('Volumetric flow [m^3/s]');title('Test III')
figure(2)
hold on
plot(C1(:,1),C1(:,2),'gx',C2(:,1),C2(:,2),'ro',C3(:,1),C3(:,2),'b+');
ylabel('Pressure[MPa]');xlabel('Volumetric flow [m^3/s]');title('Compressor Performance');
% I am using 2nd order polynomial fit for all the 3 tests
% best fit for Test I
p1=polyfit(C1(:,1),C1(:,2),2);
f1=polyval(p1,C1(:,1));
% The following table calculates the original value and compares it with the fit
T1 = table(C1(:,1),C1(:,2),f1,C1(:,2)-f1,'VariableNames',{'Volume_flow_Test_1','Pressure_Test_1','Fit','FitError_Test_1'});
plot(C1(:,1),f1,'g');
% best fit for Test II
p2=polyfit(C2(:,1),C2(:,2),2);
f2=polyval(p2,C2(:,1));
T2 = table(C2(:,1),C2(:,2),f2,C2(:,2)-f2,'VariableNames',{'Volume_flow_Test_2','Pressure_Test_2','Fit','FitError_Test_2'});
plot(C2(:,1),f2,'r');
% best fit for Test III
p3=polyfit(C3(:,1),C3(:,2),2);
f3=polyval(p3,C3(:,1));
T3 = table(C3(:,1),C3(:,2),f3,C3(:,2)-f3,'VariableNames',{'Volume_flow_Test_3','Pressure_Test_3','Fit','FitError_Test_3'});
plot(C3(:,1),f3,'b');
------------------------------------------
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.