Why is my plot blank?

1 view (last 30 days)
Katharine Gagliano
Katharine Gagliano on 8 Apr 2022
Answered: Image Analyst on 8 Apr 2022
data = readtable('clcd.xlsx');
Alpha =(data{:,1}); % Angle of Attack (deg.)
CL = (data{:,2}); % Lift Coefficient
CD = (data{:,3}); % Drag Coefficient
%%% Defining Constants %%%
N = 3; % Number of Blades
c = 0.2; % Chord Length (m)
r = 1; % Constant Radius (m)
h = 1; % Blade Height (m)
A = r*c; % Blade Cross-Sectional Area (m^2)
Th = 0:1:360; % Theta (^^^) in Array Form (deg.)
U_inf_rpm = 20; % Freestream Velocity (RPM)
U_inf_ms = 5; % Freestream Velocity (m/s)
U_inf_rad = U_inf_rpm*2*pi/60; % Freestream Velocity (rad/s)
rho = 1.225; % Air Density (kg/m^3)
%%% Time-Step Loop %%%
for jj = 1:length(Th);
tt = U_inf_rad/Th(jj); % Time (s)
V_r = U_inf_rpm*cos(Th(jj)); % Radial Velocity wr (RPM)
a_jj = atan((U_inf_rpm*sin(Th(jj)))/...
(U_inf_rpm*cos(Th(jj)) + V_r)); % Alpha for Any Given Theta (deg.)
CL_jj = interp1(Alpha,CL,a_jj); % CL for Calculated Alpha (from L.I.)
CD_jj = interp1(Alpha,CD,a_jj); % CD for Calculated Alpha (from L.I.)
V_in = sqrt((U_inf_rpm)^2 + (V_r)^2); % Inflow Velocity (m/s)
Ang_in = ((atan(U_inf_rpm/V_r)).*(180/pi)); % Inflow Angle (deg.)
segL = 0.5*rho*(V_in^2)*CL_jj*A; % Lift Force Contribution (N)
segH = abs(segL*sin(Ang_in*pi/180)); % Axial Force Contribution (N)
segQ = segH*r; % Torque Contribution (N*m)
plot(Th,segQ,'-')
hold on
grid on
title ('Torque vs/ Angular Position for a Single Blade')
end
%%% I am not receiving any error message, the plot is just blank when I run the code

Answers (2)

Torsten
Torsten on 8 Apr 2022
data = readtable('clcd.xlsx');
Alpha =(data{:,1}); % Angle of Attack (deg.)
CL = (data{:,2}); % Lift Coefficient
CD = (data{:,3}); % Drag Coefficient
%%% Defining Constants %%%
N = 3; % Number of Blades
c = 0.2; % Chord Length (m)
r = 1; % Constant Radius (m)
h = 1; % Blade Height (m)
A = r*c; % Blade Cross-Sectional Area (m^2)
Th = 0:1:360; % Theta (^^^) in Array Form (deg.)
U_inf_rpm = 20; % Freestream Velocity (RPM)
U_inf_ms = 5; % Freestream Velocity (m/s)
U_inf_rad = U_inf_rpm*2*pi/60; % Freestream Velocity (rad/s)
rho = 1.225; % Air Density (kg/m^3)
%%% Time-Step Loop %%%
segQ = zeros(size(Th));
for jj = 1:length(Th);
tt = U_inf_rad/Th(jj); % Time (s)
V_r = U_inf_rpm*cos(Th(jj)); % Radial Velocity wr (RPM)
a_jj = atan((U_inf_rpm*sin(Th(jj)))/...
(U_inf_rpm*cos(Th(jj)) + V_r)); % Alpha for Any Given Theta (deg.)
CL_jj = interp1(Alpha,CL,a_jj); % CL for Calculated Alpha (from L.I.)
CD_jj = interp1(Alpha,CD,a_jj); % CD for Calculated Alpha (from L.I.)
V_in = sqrt((U_inf_rpm)^2 + (V_r)^2); % Inflow Velocity (m/s)
Ang_in = ((atan(U_inf_rpm/V_r)).*(180/pi)); % Inflow Angle (deg.)
segL = 0.5*rho*(V_in^2)*CL_jj*A; % Lift Force Contribution (N)
segH = abs(segL*sin(Ang_in*pi/180)); % Axial Force Contribution (N)
segQ(jj) = segH*r; % Torque Contribution (N*m)
end
plot(Th,segQ,'-')
%hold on
%grid on
title ('Torque vs/ Angular Position for a Single Blade')

Image Analyst
Image Analyst on 8 Apr 2022
You're not using a marker. You're using a line, which goes between two data points. However you're not plotting two or more data points. You're plotting only one data point at a time because your plot() is inside the loop instead of outside. So to fix you need to have it plot a marker instead of a line:
plot(Th, segQ, '.', 'MarkerSize', 15); % Plot a spot/dot

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!