Properly set up axis in 3d bar plot
8 views (last 30 days)
Show older comments
Hi all, So I have built a couple matlab scripts whose purpose is to "simulate" windtunnel data. I cannot get a manual axis to function the way i am hoping. it only shows a viable plot when i allow matlab to choose the axises. The issue i have with this is that all the plots appear identical even though the data is different. Here is the 2 scripts i am running: This script is running fine, it calculates the data correctly.
function answer = efficiency()
%%Drag force equation = (1/2)pV^2CA
%p = density of air = 0.00128 g/mL
%V = velocity = variable V
%C = Coefficient of drag = variable C
%A = Cross sectional area = function A
%F = 0.5 * 0.00128(g/mL) * V^2(m/s^2) * C * A(m)
%%Selection of projectile shape
X = menu('projectile shape','sphere','cone','cube','cylinder','Streamlined body','Plots','main menu');
% Drag Coefficient
% Drag Coefficient of Sphere = 0.47
% Drag Coefficient of cone = 0.50
% Drag Coefficient of cube = 1.05
% Drag Coefficient of long cylinder = 0.82
if X == 1 % selects sphere
C = 0.47;
elseif X == 2 % selects cone
C = 0.50;
elseif X == 3 % selects cube
C = 1.05;
elseif X == 4 % selects cylinder
C = 0.82;
elseif X == 5 % Selects stremlined body
C = 0.04;
elseif X == 6 % Plots data
Plot4Final();
elseif X == 6
WindTunnel();
end
%%Overall Force Calculation
% Drag force equation = (1/2)pV^2CA
%p = density of air = 0.00128 g/mL
%V = velocity = variable V
%C = Coefficient of drag = variable C
%A = Cross sectional area = function A
%F = 0.5 * 0.00128(g/mL) * V^2(m/s^2) * C * A(m)
A = .1:.1:1; % Parameters for area
V = 100:100:1000; % Parameters for velocity
for k1 = 1:length(A)
for k2 = 1:length(V)
answer(k1,k2) = .00064*C*A(k1)*V(k2)^2;
end
end
%%create Excel spreadsheet of data
filename = 'projectiledata.xlsx';
if X == 1
xlswrite(filename,answer,1);
efficiency();
% Exports sphere data to sheet 1
elseif X == 2
xlswrite(filename,answer,2);
efficiency();
% Exports cone data to sheet 2
elseif X == 3
xlswrite(filename,answer,3);
efficiency();
% Exports cube data to sheet 3
elseif X == 4
xlswrite(filename,answer,4);
efficiency();
% Exports cylinder data to sheet 4
elseif X == 5
xlswrite(filename,answer,5);
efficiency();
% Exports cylinder data to sheet 5
end
end
This second script is where the issue lies: I believe the issue lies in axis[] which appears 5 times:
function Plot() %% Plot 1 [data] = xlsread('projectiledata.xlsx',1);
% Create the 3D bar chart
figure('Name','Spherical Projectile','NumberTitle','off');
bar3(data);
axis([100 1000 .1 .9 0 900]);
% Add title and axis labels
title('Efficiency of Spherical Shapes');
xlabel('Wind Velocity in m/s');
ylabel('Sectional Area in m');
zlabel('Overall Force applied');
% Set tick labels
%set(gca,'XTickLabel',[100,200,300,400,500,600,700,800,900,1000])
%set(gca,'YTickLabel',[0.1,0.2,0.3,0.4,0.5,0.5,0.6,0.7,0.8,0.9])
%%Plot 2
[data] = xlsread('projectiledata.xlsx',2);
% Create the 3D bar chart
figure('Name','Conical Projectile','NumberTitle','off');
bar3(data);
axis([100 1000 0.1 0.9 0 900]);
% Add title and axis labels
title('Efficiency of Conical Shapes');
xlabel('Wind Velocity in m/s');
ylabel('Sectional Area in m');
zlabel('Overall Force applied');
% Set tick labels
set(gca,'XTickLabel',[100,200,300,400,500,600,700,800,900,1000])
set(gca,'YTickLabel',[0.1,0.2,0.3,0.4,0.5,0.5,0.6,0.7,0.8,0.9])
%%Plot 3
[data] = xlsread('projectiledata.xlsx',3);
% Create the 3D bar chart
figure('Name','Cublical Projectile','NumberTitle','off');
bar3(data);
axis([100 1000 0.1 0.9 0 900]);
% Add title and axis labels
title('Efficiency of Cubical Shapes');
xlabel('Wind Velocity in m/s');
ylabel('Sectional Area in m');
zlabel('Overall Force applied');
% Set tick labels
set(gca,'XTickLabel',[100,200,300,400,500,600,700,800,900,1000])
set(gca,'YTickLabel',[0.1,0.2,0.3,0.4,0.5,0.5,0.6,0.7,0.8,0.9])
%%Plot 4
[data] = xlsread('projectiledata.xlsx',4);
% Create the 3D bar chart
figure('Name','Cylindrical Projectile','NumberTitle','off');
bar3(data);
axis([100 1000 0.1 0.9 0 900]);
% Add title and axis labels
title('Efficiency of Cylindrical Shapes');
xlabel('Wind Velocity in m/s');
ylabel('Sectional Area in m');
zlabel('Overall Force applied');
% Set tick labels
set(gca,'XTickLabel',[100,200,300,400,500,600,700,800,900,1000])
set(gca,'YTickLabel',[0.1,0.2,0.3,0.4,0.5,0.5,0.6,0.7,0.8,0.9])
%%Plot 4
[data] = xlsread('projectiledata.xlsx',5);
% Create the 3D bar chart
figure('Name','Streamlined Projectile','NumberTitle','off');
bar3(data);
axis([100 1000 0.1 0.9 0 900]);
% Add title and axis labels
title('Efficiency of streamlined Shapes');
xlabel('Wind Velocity in m/s');
ylabel('Sectional Area in m');
zlabel('Overall Force applied');
% Set tick labels
set(gca,'XTickLabel',[100,200,300,400,500,600,700,800,900,1000])
set(gca,'YTickLabel',[0.1,0.2,0.3,0.4,0.5,0.5,0.6,0.7,0.8,0.9])
%%Open Excel file for viewing
winopen('projectiledata.xlsx')
end
3 Comments
Answers (0)
See Also
Categories
Find more on Bar 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!