Plot Function not displaying all points in data set

6 Ansichten (letzte 30 Tage)
Sam Blake
Sam Blake am 11 Okt. 2023
Kommentiert: Walter Roberson am 12 Okt. 2023
Hello I am trying to plot two arrays of 13x1, one in the x-axis and the other in the y-axis, when I go to plot these, I am only recieving 7 out of the 13 data points. The two 13x1 doubles are velocity35 or velocity60 as the y and plotted against it is radius, in the x. I have attached the code as well as the excel file the data comes from. I really have no idea why im not getting the full dataset, I have tryed messing with the x and y limits of the axis but apart from that Im stumped. If anyone can spot why when you plot make these plots, I am only getting 7 data points instead of the full 13 points that are held within each variable, Id really appreciate you. Thanks!
clc;clear; close all
x = importdata('TFL Lab 1.xlsx');
Warning: File contains uninterpretable data.
rho_air = 0.0765; %lb/ft cubed
%draw values from spreadsheet
Height60 = x.data(3:15,4); Dynamic_Pressure60 = x.data(3:15,7) ;
Index in position 1 exceeds array bounds.
Height35 = x.data(16:28,4); Dynamic_Pressure35 = x.data(16:28,7);
%converting values to radii and velocity
radius = [2.365/2 2.262/2 2.148/2 2.019/2 1.865/2 1.665/2 1.183/2 1.665/2 1.865/2 2.019/2 2.148/2 2.262/2 2.365/2]'
velocity60 = 60 ./ (pi.*radius.^2); %calculating velocity by Q=V*A->V=Q/A
velocity35 = 35 ./ (pi.*radius.^2);
%Plotting Theoretical Curves
U35_laminar = max(velocity35)*(1-(radius/1.25).^2);
U35_turbulent = max(velocity35)*(1-(radius/1.25).^(1/8));
U60_laminar = max(velocity60)*(1-(radius/1.25).^2);
U60_turbulent = max(velocity60)*(1-(radius/1.25).^(1/8));
%low flow rate velocity profile
figure(1)
hold on
plot(radius,velocity35,'r')
plot(radius,U35_laminar,'g')
plot(radius,U35_turbulent,'b')
legend('Observed Velocity','Theoretical Laminar Curve','Theoretical Turbulent Curve')
title('35 GPM Velocity Profile versus Theoretical Curves' )
xlabel("Radius in inches") ; ylabel("Velocity in inches per minute")
hold off
%high flow rate velocity profile
figure(2)
hold on
plot(radius,velocity60,'r')
plot(radius,U60_laminar,'g')
plot(radius,U60_turbulent,'b')
legend('Observed Velocity','Theoretical Laminar Curve','Theoretical Turbulent Curve')
title('60 GPM Velocity Profile' )
xlabel("Radius in inches") ; ylabel("Velocity in inches per minute")
hold off
  1 Kommentar
Sam Blake
Sam Blake am 12 Okt. 2023
One thing for clarification: This code was ran in Matlab 2023a, i have that entered into the question information but it wont change.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 11 Okt. 2023
You have duplicate radius values. Also, the radius values are not sorted.
OFF = @(R)R-1;
x.data = readmatrix('TFL Lab 1.xlsx');
rho_air = 0.0765; %lb/ft cubed
%draw values from spreadsheet
Height60 = x.data(OFF(3:15),4); Dynamic_Pressure60 = x.data(OFF(3:15),7) ;
Height35 = x.data(OFF(16:28),4); Dynamic_Pressure35 = x.data(OFF(16:28),7);
%converting values to radii and velocity
radius = [2.365/2 2.262/2 2.148/2 2.019/2 1.865/2 1.665/2 1.183/2 1.665/2 1.865/2 2.019/2 2.148/2 2.262/2 2.365/2]' ;
numel(radius)
ans = 13
numel(unique(radius))
ans = 7
velocity60 = 60 ./ (pi.*radius.^2); %calculating velocity by Q=V*A->V=Q/A
velocity35 = 35 ./ (pi.*radius.^2);
%Plotting Theoretical Curves
U35_laminar = max(velocity35)*(1-(radius/1.25).^2);
U35_turbulent = max(velocity35)*(1-(radius/1.25).^(1/8));
U60_laminar = max(velocity60)*(1-(radius/1.25).^2);
U60_turbulent = max(velocity60)*(1-(radius/1.25).^(1/8));
%low flow rate velocity profile
figure(1)
hold on
plot(radius,velocity35,'r-*')
plot(radius,U35_laminar,'g-*')
plot(radius,U35_turbulent,'b-*')
legend('Observed Velocity','Theoretical Laminar Curve','Theoretical Turbulent Curve')
title('35 GPM Velocity Profile versus Theoretical Curves' )
xlabel("Radius in inches") ; ylabel("Velocity in inches per minute")
hold off
%high flow rate velocity profile
figure(2)
hold on
plot(radius,velocity60,'r-*')
plot(radius,U60_laminar,'g-*')
plot(radius,U60_turbulent,'b-*')
legend('Observed Velocity','Theoretical Laminar Curve','Theoretical Turbulent Curve')
title('60 GPM Velocity Profile' )
xlabel("Radius in inches") ; ylabel("Velocity in inches per minute")
hold off
nnz(~isfinite(velocity35))
ans = 0
nnz(~isfinite(U35_laminar))
ans = 0
nnz(~isfinite(U35_turbulent))
ans = 0
nnz(~isfinite(velocity60))
ans = 0
nnz(~isfinite(U60_laminar))
ans = 0
nnz(~isfinite(U60_turbulent))
ans = 0
  2 Kommentare
Sam Blake
Sam Blake am 12 Okt. 2023
Thank you for pointing out the duplicate values! They are distances so Im able to represent some as negatives. Im not really sure what you mean by the values are not sorted.
Walter Roberson
Walter Roberson am 12 Okt. 2023
OFF = @(R)R-1;
x.data = readmatrix('TFL Lab 1.xlsx');
rho_air = 0.0765; %lb/ft cubed
%draw values from spreadsheet
Height60 = x.data(OFF(3:15),4); Dynamic_Pressure60 = x.data(OFF(3:15),7) ;
Height35 = x.data(OFF(16:28),4); Dynamic_Pressure35 = x.data(OFF(16:28),7);
%converting values to radii and velocity
radius_differences = [2.365/2 2.262/2 2.148/2 2.019/2 1.865/2 1.665/2 1.183/2 1.665/2 1.865/2 2.019/2 2.148/2 2.262/2 2.365/2]' ;
radius = cumsum(radius_differences);
numel(radius)
ans = 13
numel(unique(radius))
ans = 13
velocity60 = 60 ./ (pi.*radius.^2); %calculating velocity by Q=V*A->V=Q/A
velocity35 = 35 ./ (pi.*radius.^2);
%Plotting Theoretical Curves
U35_laminar = max(velocity35)*(1-(radius/1.25).^2);
U35_turbulent = max(velocity35)*(1-(radius/1.25).^(1/8));
U60_laminar = max(velocity60)*(1-(radius/1.25).^2);
U60_turbulent = max(velocity60)*(1-(radius/1.25).^(1/8));
%low flow rate velocity profile
figure(1)
hold on
plot(radius,velocity35,'r-*')
plot(radius,U35_laminar,'g-*')
plot(radius,U35_turbulent,'b-*')
legend({'Observed Velocity','Theoretical Laminar Curve','Theoretical Turbulent Curve'}, 'Location', 'best')
title('35 GPM Velocity Profile versus Theoretical Curves' )
xlabel("Radius in inches") ; ylabel("Velocity in inches per minute")
hold off
%high flow rate velocity profile
figure(2)
hold on
plot(radius,velocity60,'r-*')
plot(radius,U60_laminar,'g-*')
plot(radius,U60_turbulent,'b-*')
legend({'Observed Velocity','Theoretical Laminar Curve','Theoretical Turbulent Curve'}, 'Location', 'best');
title('60 GPM Velocity Profile' )
xlabel("Radius in inches") ; ylabel("Velocity in inches per minute")
hold off
nnz(~isfinite(velocity35))
ans = 0
nnz(~isfinite(U35_laminar))
ans = 0
nnz(~isfinite(U35_turbulent))
ans = 0
nnz(~isfinite(velocity60))
ans = 0
nnz(~isfinite(U60_laminar))
ans = 0
nnz(~isfinite(U60_turbulent))
ans = 0

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by