Need a tangent line in my plot like the example provided but I cannot seem to do it
I am trying to make a tangent or line of best fit t this data but only from the second half of the plot on should be focused on. Below is an example from the professor
Need smething like this…
which translates to something like this…
But for some reason I keep getting this…
By using this code…
%% Calculation Problem 2
%Given Data Problems 1-4
dd = load(‘NEWPROB6.txt’) %Data loading for airfoil
alpha = dd(:,1); %Angle of attacks (Degreed)
CL = dd(:,2); %Lift coefficient
CD = dd(:,3); %Drag coefficient
Rh = 0.75; %Turbine hub radius (m)
Rt = 15; %Turbine blade tip radius (m)
Rht = linspace(Rh,Rt,10); %r/R radius hub to tip (m)
Rr = Rht/Rt;
B = 3; %Number of blades on the turbine
TSR = 8; %Tips-speed ratio
%Calculation Problem 1
CLD = CL./CD %Lift-to-Drag Ratio
TCL = 1.0280 %Lift coefficient associated with maximum lift-to-drag ratio
Talpha = 6 %Target angle of attack (degrees)
%Calculation Problem 2
Phi = atand(2./(3*TSR*(Rr))) %Local inflow angle (degrees)
CrR = Rt*(8*pi*sind(Phi))./(3*B*TCL*TSR); %chord distribution
Beta = Phi-Talpha
subplot(2,1,1)
plot(Rht,CrR, ‘b.-‘, ‘LineWidth’,2, ‘MarkerSize’, 20)
halfpoints = round(numel(CrR)/2)
xlabel(‘r/R’)
ylabel(‘Chord Distribution (m)’)
grid on
hold on
% Assume x and y are your data vectors
xline(Rht(halfpoints), ‘Color’, ‘r’)
% Get halfway index
RhtHalf = Rht(halfpoints : end)
CrRHalf = CrR(halfpoints : end)
coefficients = polyfit(RhtHalf, CrRHalf, 1)
RhtFitted = linspace(5, 10, 1)
CrRFitted = polyval(coefficients, RhtFitted);
plot(RhtFitted, CrRFitted, ‘c–‘, ‘LineWidth’, 2)
grid on
legend(‘Original Data’, ‘Linear Fit (2nd Half)’);
hold off
Does anyone know how I can fix this?I am trying to make a tangent or line of best fit t this data but only from the second half of the plot on should be focused on. Below is an example from the professor
Need smething like this…
which translates to something like this…
But for some reason I keep getting this…
By using this code…
%% Calculation Problem 2
%Given Data Problems 1-4
dd = load(‘NEWPROB6.txt’) %Data loading for airfoil
alpha = dd(:,1); %Angle of attacks (Degreed)
CL = dd(:,2); %Lift coefficient
CD = dd(:,3); %Drag coefficient
Rh = 0.75; %Turbine hub radius (m)
Rt = 15; %Turbine blade tip radius (m)
Rht = linspace(Rh,Rt,10); %r/R radius hub to tip (m)
Rr = Rht/Rt;
B = 3; %Number of blades on the turbine
TSR = 8; %Tips-speed ratio
%Calculation Problem 1
CLD = CL./CD %Lift-to-Drag Ratio
TCL = 1.0280 %Lift coefficient associated with maximum lift-to-drag ratio
Talpha = 6 %Target angle of attack (degrees)
%Calculation Problem 2
Phi = atand(2./(3*TSR*(Rr))) %Local inflow angle (degrees)
CrR = Rt*(8*pi*sind(Phi))./(3*B*TCL*TSR); %chord distribution
Beta = Phi-Talpha
subplot(2,1,1)
plot(Rht,CrR, ‘b.-‘, ‘LineWidth’,2, ‘MarkerSize’, 20)
halfpoints = round(numel(CrR)/2)
xlabel(‘r/R’)
ylabel(‘Chord Distribution (m)’)
grid on
hold on
% Assume x and y are your data vectors
xline(Rht(halfpoints), ‘Color’, ‘r’)
% Get halfway index
RhtHalf = Rht(halfpoints : end)
CrRHalf = CrR(halfpoints : end)
coefficients = polyfit(RhtHalf, CrRHalf, 1)
RhtFitted = linspace(5, 10, 1)
CrRFitted = polyval(coefficients, RhtFitted);
plot(RhtFitted, CrRFitted, ‘c–‘, ‘LineWidth’, 2)
grid on
legend(‘Original Data’, ‘Linear Fit (2nd Half)’);
hold off
Does anyone know how I can fix this? I am trying to make a tangent or line of best fit t this data but only from the second half of the plot on should be focused on. Below is an example from the professor
Need smething like this…
which translates to something like this…
But for some reason I keep getting this…
By using this code…
%% Calculation Problem 2
%Given Data Problems 1-4
dd = load(‘NEWPROB6.txt’) %Data loading for airfoil
alpha = dd(:,1); %Angle of attacks (Degreed)
CL = dd(:,2); %Lift coefficient
CD = dd(:,3); %Drag coefficient
Rh = 0.75; %Turbine hub radius (m)
Rt = 15; %Turbine blade tip radius (m)
Rht = linspace(Rh,Rt,10); %r/R radius hub to tip (m)
Rr = Rht/Rt;
B = 3; %Number of blades on the turbine
TSR = 8; %Tips-speed ratio
%Calculation Problem 1
CLD = CL./CD %Lift-to-Drag Ratio
TCL = 1.0280 %Lift coefficient associated with maximum lift-to-drag ratio
Talpha = 6 %Target angle of attack (degrees)
%Calculation Problem 2
Phi = atand(2./(3*TSR*(Rr))) %Local inflow angle (degrees)
CrR = Rt*(8*pi*sind(Phi))./(3*B*TCL*TSR); %chord distribution
Beta = Phi-Talpha
subplot(2,1,1)
plot(Rht,CrR, ‘b.-‘, ‘LineWidth’,2, ‘MarkerSize’, 20)
halfpoints = round(numel(CrR)/2)
xlabel(‘r/R’)
ylabel(‘Chord Distribution (m)’)
grid on
hold on
% Assume x and y are your data vectors
xline(Rht(halfpoints), ‘Color’, ‘r’)
% Get halfway index
RhtHalf = Rht(halfpoints : end)
CrRHalf = CrR(halfpoints : end)
coefficients = polyfit(RhtHalf, CrRHalf, 1)
RhtFitted = linspace(5, 10, 1)
CrRFitted = polyval(coefficients, RhtFitted);
plot(RhtFitted, CrRFitted, ‘c–‘, ‘LineWidth’, 2)
grid on
legend(‘Original Data’, ‘Linear Fit (2nd Half)’);
hold off
Does anyone know how I can fix this? tangent line, line of best fit, regression line, plotting, matlab MATLAB Answers — New Questions