One thing for clarification: This code was ran in Matlab 2023a, i have that entered into the question information but it wont change.
Plot Function not displaying all points in data set
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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');
rho_air = 0.0765; %lb/ft cubed
%draw values from spreadsheet
Height60 = x.data(3:15,4); Dynamic_Pressure60 = x.data(3:15,7) ;
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
Akzeptierte Antwort
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)
numel(unique(radius))
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))
nnz(~isfinite(U35_laminar))
nnz(~isfinite(U35_turbulent))
nnz(~isfinite(velocity60))
nnz(~isfinite(U60_laminar))
nnz(~isfinite(U60_turbulent))
2 Kommentare
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)
numel(unique(radius))
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))
nnz(~isfinite(U35_laminar))
nnz(~isfinite(U35_turbulent))
nnz(~isfinite(velocity60))
nnz(~isfinite(U60_laminar))
nnz(~isfinite(U60_turbulent))
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Choose and Parameterize Blocks finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!