Why my plot doesn't show up all of it?
1 次查看(过去 30 天)
显示 更早的评论
Hi all, I want to plot 11 graphs in one image, but only 2 plots appear in the graph. how to display all plots in one graph? following is my code:
%% Beam Properties
L = 0.35; % Length of the beam (m)
w = 0.02; % Width of the beam (m)
t = 0.002; % thickness of the beam (m)
m = 0.024; % Mass of the point mass (kg)
E = 200e9; % Young's Modulus (Pa)
rho = 7850; % Density of the material
Acs = w*t; %cross sectional area
I = w*t^3/12; %second moment of inertia
A = 1;
n = 11;
beta_exp_1 = 1.6001/L;
beta_exp_2 = 4.2503/L;
% Nat freq (Hz)
freq_tip_1 = 9.3582;
freq_tip_2 = 68.8662;
freq_30_1 = 9.4122;
freq_30_2 = 69.77;
freq_60_1 = 9.3824;
freq_60_2 = 67.1689;
freq_90_1 = 9.4563;
freq_90_2 = 68.9068;
freq_120_1 = 9.4967;
freq_120_2 = 68.9036;
freq_150_1 = 9.4383;
freq_150_2 = 68.8971;
freq_210_1 = 9.2328;
freq_210_2 = 68.932;
freq_240_1 = 9.14;
freq_240_2 = 68.9545;
freq_270_1 = 9.8205;
freq_270_2 = 69.0093;
freq_300_1 = 9.6313;
freq_300_2 = 69.0655;
freq_330_2 = 69.1462;
% Beta
beta_tip_1 = sqrt(sqrt(((rho*Acs*((freq_tip_1*(2*pi))^2)))/E*I));
beta_tip_2 = sqrt(sqrt(((rho*Acs*((freq_tip_2*(2*pi))^2)))/E*I));
beta_30_1 = sqrt(sqrt(((rho*Acs*((freq_30_1*(2*pi))^2)))/E*I));
beta_30_2 = sqrt(sqrt(((rho*Acs*((freq_30_2*(2*pi))^2)))/E*I));
beta_60_1 = sqrt(sqrt(((rho*Acs*((freq_60_1*(2*pi))^2)))/E*I));
beta_60_2 = sqrt(sqrt(((rho*Acs*((freq_60_2*(2*pi))^2)))/E*I));
beta_90_1 = sqrt(sqrt(((rho*Acs*((freq_90_1*(2*pi))^2)))/E*I));
beta_90_2 = sqrt(sqrt(((rho*Acs*((freq_90_2*(2*pi))^2)))/E*I));
beta_120_1 = sqrt(sqrt(((rho*Acs*((freq_120_1*(2*pi))^2)))/E*I));
beta_120_2 = sqrt(sqrt(((rho*Acs*((freq_120_2*(2*pi))^2)))/E*I));
beta_150_1 = sqrt(sqrt(((rho*Acs*((freq_150_1*(2*pi))^2)))/E*I));
beta_150_2 = sqrt(sqrt(((rho*Acs*((freq_150_2*(2*pi))^2)))/E*I));
beta_210_1 = sqrt(sqrt(((rho*Acs*((freq_210_1*(2*pi))^2)))/E*I));
beta_210_2 = sqrt(sqrt(((rho*Acs*((freq_210_2*(2*pi))^2)))/E*I));
beta_240_1 = sqrt(sqrt(((rho*Acs*((freq_240_1*(2*pi))^2)))/E*I));
beta_240_2 = sqrt(sqrt(((rho*Acs*((freq_240_2*(2*pi))^2)))/E*I));
beta_270_1 = sqrt(sqrt(((rho*Acs*((freq_270_1*(2*pi))^2)))/E*I));
beta_270_2 = sqrt(sqrt(((rho*Acs*((freq_270_2*(2*pi))^2)))/E*I));
beta_300_1 = sqrt(sqrt(((rho*Acs*((freq_300_1*(2*pi))^2)))/E*I));
beta_300_2 = sqrt(sqrt(((rho*Acs*((freq_300_2*(2*pi))^2)))/E*I));
beta_330_2 = sqrt(sqrt(((rho*Acs*((freq_330_2*(2*pi))^2)))/E*I));
%% Plotting Mode Shapes
beta1 = [beta_exp_1 beta_tip_1 beta_30_1 beta_60_1 beta_90_1 beta_120_1 beta_150_1 beta_210_1 beta_240_1 beta_270_1 beta_300_1];
x = linspace(0,L,100); % Discretized beam length
mode_shape = zeros(n,100);
for i = 1:n
mode_shape(i,:) = A*((sin(beta1(i)*x)-sinh(beta1(i)*x))-(((sin(beta1(i)*L)+sinh(beta1(i)*L))./(cos(beta1(i)*L)+cosh(beta1(i)*L))).*(cos(beta1(i)*x)-cosh(beta1(i)*x)))); % Mode Shapes
mode_shape(i,:) = mode_shape(i,:)./max(abs(mode_shape(i,:))); % Normalize Mode Shapes
plot(x,mode_shape(i,:))
hold on
end
figure(1);
xlabel('x(m)')
ylabel('Mode Shape')
title('Mode Shapes 1 of The Beam')
legend('experimental','tip','30','60','90','120','150','210','240','270','300'); grid
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1355588/image.png)
Thank you in advance,
0 个评论
采纳的回答
Star Strider
2023-4-14
All the curves are plotted, however they appear to be overplotted on top of each other.
Plotting them using plot3 with an offset variable demonstrates this —
%% Beam Properties
L = 0.35; % Length of the beam (m)
w = 0.02; % Width of the beam (m)
t = 0.002; % thickness of the beam (m)
m = 0.024; % Mass of the point mass (kg)
E = 200e9; % Young's Modulus (Pa)
rho = 7850; % Density of the material
Acs = w*t; %cross sectional area
I = w*t^3/12; %second moment of inertia
A = 1;
n = 11;
beta_exp_1 = 1.6001/L;
beta_exp_2 = 4.2503/L;
% Nat freq (Hz)
freq_tip_1 = 9.3582;
freq_tip_2 = 68.8662;
freq_30_1 = 9.4122;
freq_30_2 = 69.77;
freq_60_1 = 9.3824;
freq_60_2 = 67.1689;
freq_90_1 = 9.4563;
freq_90_2 = 68.9068;
freq_120_1 = 9.4967;
freq_120_2 = 68.9036;
freq_150_1 = 9.4383;
freq_150_2 = 68.8971;
freq_210_1 = 9.2328;
freq_210_2 = 68.932;
freq_240_1 = 9.14;
freq_240_2 = 68.9545;
freq_270_1 = 9.8205;
freq_270_2 = 69.0093;
freq_300_1 = 9.6313;
freq_300_2 = 69.0655;
freq_330_2 = 69.1462;
% Beta
beta_tip_1 = sqrt(sqrt(((rho*Acs*((freq_tip_1*(2*pi))^2)))/E*I));
beta_tip_2 = sqrt(sqrt(((rho*Acs*((freq_tip_2*(2*pi))^2)))/E*I));
beta_30_1 = sqrt(sqrt(((rho*Acs*((freq_30_1*(2*pi))^2)))/E*I));
beta_30_2 = sqrt(sqrt(((rho*Acs*((freq_30_2*(2*pi))^2)))/E*I));
beta_60_1 = sqrt(sqrt(((rho*Acs*((freq_60_1*(2*pi))^2)))/E*I));
beta_60_2 = sqrt(sqrt(((rho*Acs*((freq_60_2*(2*pi))^2)))/E*I));
beta_90_1 = sqrt(sqrt(((rho*Acs*((freq_90_1*(2*pi))^2)))/E*I));
beta_90_2 = sqrt(sqrt(((rho*Acs*((freq_90_2*(2*pi))^2)))/E*I));
beta_120_1 = sqrt(sqrt(((rho*Acs*((freq_120_1*(2*pi))^2)))/E*I));
beta_120_2 = sqrt(sqrt(((rho*Acs*((freq_120_2*(2*pi))^2)))/E*I));
beta_150_1 = sqrt(sqrt(((rho*Acs*((freq_150_1*(2*pi))^2)))/E*I));
beta_150_2 = sqrt(sqrt(((rho*Acs*((freq_150_2*(2*pi))^2)))/E*I));
beta_210_1 = sqrt(sqrt(((rho*Acs*((freq_210_1*(2*pi))^2)))/E*I));
beta_210_2 = sqrt(sqrt(((rho*Acs*((freq_210_2*(2*pi))^2)))/E*I));
beta_240_1 = sqrt(sqrt(((rho*Acs*((freq_240_1*(2*pi))^2)))/E*I));
beta_240_2 = sqrt(sqrt(((rho*Acs*((freq_240_2*(2*pi))^2)))/E*I));
beta_270_1 = sqrt(sqrt(((rho*Acs*((freq_270_1*(2*pi))^2)))/E*I));
beta_270_2 = sqrt(sqrt(((rho*Acs*((freq_270_2*(2*pi))^2)))/E*I));
beta_300_1 = sqrt(sqrt(((rho*Acs*((freq_300_1*(2*pi))^2)))/E*I));
beta_300_2 = sqrt(sqrt(((rho*Acs*((freq_300_2*(2*pi))^2)))/E*I));
beta_330_2 = sqrt(sqrt(((rho*Acs*((freq_330_2*(2*pi))^2)))/E*I));
%% Plotting Mode Shapes
beta1 = [beta_exp_1 beta_tip_1 beta_30_1 beta_60_1 beta_90_1 beta_120_1 beta_150_1 beta_210_1 beta_240_1 beta_270_1 beta_300_1];
x = linspace(0,L,100); % Discretized beam length
mode_shape = zeros(n,100);
figure
for i = 1:n
mode_shape(i,:) = A*((sin(beta1(i)*x)-sinh(beta1(i)*x))-(((sin(beta1(i)*L)+sinh(beta1(i)*L))./(cos(beta1(i)*L)+cosh(beta1(i)*L))).*(cos(beta1(i)*x)-cosh(beta1(i)*x)))); % Mode Shapes
mode_shape(i,:) = mode_shape(i,:)./max(abs(mode_shape(i,:))); % Normalize Mode Shapes
ofst = ones(size(x))*i; % Create Offset Variable,
plot3(ofst,x,mode_shape(i,:)) % Plot Using 'plot3'
hold on
end
% figure(1);
xlabel('x(m)')
ylabel('Mode Shape')
title('Mode Shapes 1 of The Beam')
legend('experimental','tip','30','60','90','120','150','210','240','270','300'); grid
If the mode shapes are supposed to be visibly different, you need to check your code to determine the reason they are not.
If you are using degrees as the angular measure, use the sind and cosd functions instead of sin and cos, that take their arguments in radian angular measure.
Also, your code would be significantly easier to write and understand if you created indexed variables rather than completely new, individually-named variables
.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!