Making curves reach axes
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I am trying to make a plot of the power generated by a rising helium balloon in function of its hight for different balloonvolumes. The curves of the smallest 2 balloons dont go all the way down to zero on the plot (or reach the x-axis) wich makes them akwardly float. I tried to modify the y-axis range but it doesn't work.
Vb0_vec = [10 100 250 1000];
mb_vec = (20*10^-3)*(36*pi*Vb0_vec.^2).^(1/3);
lambda = 0.0173;
rhog0 = 0.169;
Cw = 0.41;
y = linspace(0, 11000, 2000);
% Plot 4: vermogen ifv de hoogte voor vershillende ballonvolumes
P_10 = Power(y, Vb0_vec(1), lambda, mb_vec(1), rhog0, Cw);
P_100 = Power(y, Vb0_vec(2), lambda, mb_vec(2), rhog0, Cw);
P_250 = Power(y, Vb0_vec(3), lambda, mb_vec(3), rhog0, Cw);
P_1000 = Power(y, Vb0_vec(4), lambda, mb_vec(4), rhog0, Cw);
figure()
semilogy(y, P_10, 'b-', 'LineWidth', 2)
hold on
semilogy(y, P_100, 'LineWidth', 2)
semilogy(y, P_250, 'r--', 'LineWidth', 2)
semilogy(y, P_1000, 'g:', 'LineWidth', 2)
hold off
ylabel("Vermogen (W)")
xlabel("Hoogte (m)")
title("Momentaan geleverd vermogen over het traject voor verschillende ballonvolumes",...
"FontSize", 16)
legend("10 m³", "100 m³", "250 m³", "1000 m³", "Location", "southeast")
% volgende code zorgt dat de curves mooi doorlopen tot aan de assen
ymin_10 = min(P_10);
ymin_100 = min(P_100);
ymin = max(ymin_10, ymin_100);
ylim = [ymin, 10^5];
xlim([0 11000])
This is the code for the function Power, LoadConstants loads all the necessary parameters/constants:
unction [P] = Power(y, Vb0, lambda, mb, rhog0, Cw)
% vaste parameters
LoadConstants
% tussenberekeningen
% krachten
Fa = rhol0*Vb0*g;
Fzk = lambda*y*g;
Fzb = (rhog0*Vb0+mb)*g;
% hoogteafhankelijke parameters
Vb = Vb0*(1-y*L/Tl0).^(1-(g*Ml/(R*L)));
rhol = rhol0*(1-y*L/Tl0).^((g*Ml/(R*L))-1);
rb = ((3*Vb)/(4*pi)).^(1/3);
Ab = pi*rb.^2;
% vermogen
P = (2/3)*sqrt(2/3)*sqrt(((Fa-Fzb-Fzk).^3)./(Ab*Cw.*rhol));
end
Output of the plot:

Thank you
2 Kommentare
VBBV
am 29 Mär. 2025
The syntax for ylim function can be referred here
https://www.mathworks.com/help/matlab/ref/ylim.html
Akzeptierte Antwort
VBBV
am 29 Mär. 2025
@Arne Those are the smallest values for equations in your program. if you want them to touch the axis, use
ylim([0.1 1e5])
1 Kommentar
VBBV
am 29 Mär. 2025
Vb0_vec = [10 100 250 1000];
mb_vec = (20*10^-3)*(36*pi*Vb0_vec.^2).^(1/3);
lambda = 0.0173;
rhog0 = 0.169;
Cw = 0.41;
y = linspace(0, 11000, 2000);
% Plot 4: vermogen ifv de hoogte voor vershillende ballonvolumes
P_10 = Power(y, Vb0_vec(1), lambda, mb_vec(1), rhog0, Cw);
P_100 = Power(y, Vb0_vec(2), lambda, mb_vec(2), rhog0, Cw);
P_250 = Power(y, Vb0_vec(3), lambda, mb_vec(3), rhog0, Cw);
P_1000 = Power(y, Vb0_vec(4), lambda, mb_vec(4), rhog0, Cw);
figure()
semilogy(y, P_10, 'b-', 'LineWidth', 2)
hold on
semilogy(y, P_100, 'LineWidth', 2)
semilogy(y, P_250, 'r--', 'LineWidth', 2)
semilogy(y, P_1000, 'g:', 'LineWidth', 2)
hold off
ylabel("Vermogen (W)")
xlabel("Hoogte (m)")
title("Momentaan geleverd vermogen over het traject voor verschillende ballonvolumes",...
"FontSize", 16)
ymin_10 = min(P_10);
ymin_100 = min(P_100);
ymin = max(ymin_10, ymin_100);
%ylim = [ymin, 10^5];
ylim([0.1 1e5])
xlim([0 11000])
%ymin_100 = min(P_100);ymin = max(ymin_10, ymin_100);ylim = [ymin, 10^5];xlim([0 11000])
function [P] = Power(y, Vb0, lambda, mb, rhog0, Cw)
% vaste parameters
%LoadConstants
% tussenberekeningen
% krachten
rhol0 = 1.225;
L = 0.0065;
Tl0 =288.15;
R = 8.314;
g = 9.81;
Ml = 0.02896;
Pl0 =101325;
Cw = 0.285
%L = 0.0065;Tl0 =288.15;R = 8.314;g = 9.81;Ml = 0.02896;Pl0 =101325;Cw = 0.285
Fa = rhol0*Vb0*g;
Fzk = lambda*y*g;
Fzb = (rhog0*Vb0+mb)*g;
% hoogteafhankelijke parameters
Vb = Vb0*(1-y*L/Tl0).^(1-(g*Ml/(R*L)));
rhol = rhol0*(1-y*L/Tl0).^((g*Ml/(R*L))-1);
rb = ((3*Vb)/(4*pi)).^(1/3);
Ab = pi*rb.^2;
% vermogen
P = (2/3)*sqrt(2/3)*sqrt(((Fa-Fzb-Fzk).^3)./(Ab*Cw.*rhol));
end% vaste parametersLoadConstants% tussenberekeningen% krachtenFa = rhol0*Vb0*g;Fzk = lambda*y*g;Fzb = (rhog0*Vb0+mb)*g;% hoogteafhankelijke parametersVb = Vb0*(1-y*L/Tl0).^(1-(g*Ml/(R*L)));rhol = rhol0*(1-y*L/Tl0).^((g*Ml/(R*L))-1); rb = ((3*Vb)/(4*pi)).^(1/3);Ab = pi*rb.^2;% vermogenP = (2/3)*sqrt(2/3)*sqrt(((Fa-Fzb-Fzk).^3)./(Ab*Cw.*rhol));end
%mb_vec = (20*10^-3)*(36*pi*Vb0_vec.^2).^(1/3);lambda = 0.0173;rhog0 = 0.169;Cw = 0.41;y = linspace(0, 11000, 2000);% Plot 4: vermogen ifv de hoogte voor vershillende ballonvolumesP_10 = Power(y, Vb0_vec(1), lambda, mb_vec(1), rhog0, Cw);P_100 = Power(y, Vb0_vec(2), lambda, mb_vec(2), rhog0, Cw);P_250 = Power(y, Vb0_vec(3), lambda, mb_vec(3), rhog0, Cw);P_1000 = Power(y, Vb0_vec(4), lambda, mb_vec(4), rhog0, Cw);figure()semilogy(y, P_10, 'b-', 'LineWidth', 2)hold onsemilogy(y, P_100, 'LineWidth', 2)semilogy(y, P_250, 'r--', 'LineWidth', 2)semilogy(y, P_1000, 'g:', 'LineWidth', 2)hold offylabel("Vermogen (W)")xlabel("Hoogte (m)")title("Momentaan geleverd vermogen over het traject voor verschillende ballonvolumes",... "FontSize", 16)
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Vibration Analysis 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!
