- Technical Services and Consulting
- Embedded Systems | Firmware Developement | Simulations
- Electrical and Electronics Engineering
How do I plot a function up to a certain value and start another function at that value for the same plot?
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I'm plotting the power on a hydraulic cylinder over the angle of tilt of the beam that the cylinder is pushing. This is the code I have, and for the plot I want the "red line" to stop at a value of 2, and the "blue line" to start at the value of 2. How do I go about this?
Also, is it possible to connect both lines to represent a drop in power?
This is code:
%Calculations for tilting ONLY
AC=2.125;
Fc=8130.0375;
BD=2;
A=0.03^2.*pi;
%Varying angles
a = 0:45;
Deg=sind(a);
FhN=2.125*Fc*Deg;
Fh=FhN/(BD*2*sind(10));
Ph=(Fh/A)/100000;
P_max=Fh*0.237;
P_rest=Fh*0.147;
% Power on Cylinder for Tilting
figure(1)
subplot(2,2,3)
plot(a,P_max,'r',a,P_rest,'b')
title('Power on HC')
axis([0 inf, 0 inf])
xlabel('Angle')
ylabel('Power [W]')
0 Commenti
Risposta accettata
Hassaan
il 22 Mar 2024
% Calculations for tilting ONLY
AC = 2.125;
Fc = 8130.0375;
BD = 2;
A = 0.03^2 * pi;
% Varying angles
a = 0:45; % Angle range
Deg = sind(a); % Sine of angles
FhN = 2.125 * Fc * Deg; % Normal force
Fh = FhN / (BD * 2 * sind(10)); % Horizontal force
Ph = (Fh / A) / 100000; % Hydraulic power
P_max = Fh * 0.237; % Max power
P_rest = Fh * 0.147; % Resting power
% Determine the index where angle is 2 degrees
angleLimit = 2;
idxLimit = find(a >= angleLimit, 1);
% Power on Cylinder for Tilting
figure(1)
subplot(2,2,3)
% Plot red line up to angle of 2 degrees, including the point at 2 degrees
plot(a(1:idxLimit), P_max(1:idxLimit), 'r')
hold on; % Hold on to plot on the same axes
% Plot blue line starting from angle of 2 degrees
plot(a(idxLimit:end), P_rest(idxLimit:end), 'b')
% Optionally, connect the two lines directly to represent a drop in power
% Find the last point of the red line and the first point of the blue line
lastPointRed = [a(idxLimit), P_max(idxLimit)];
firstPointBlue = [a(idxLimit), P_rest(idxLimit)];
% Plot a black line connecting these points
plot([lastPointRed(1), firstPointBlue(1)], [lastPointRed(2), firstPointBlue(2)], 'k--')
hold off; % Release the hold
% Additional plot settings
title('Power on HC')
axis([0 inf, 0 inf])
xlabel('Angle')
ylabel('Power [W]')
-----------------------------------------------------------------------------------------------------------------------------------------------------
If you find the solution helpful and it resolves your issue, it would be greatly appreciated if you could accept the answer. Also, leaving an upvote and a comment are also wonderful ways to provide feedback.
It's important to note that the advice and code are based on limited information and meant for educational purposes. Users should verify and adapt the code to their specific needs, ensuring compatibility and adherence to ethical standards.
Professional Interests
Feel free to contact me.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Antennas, Microphones, and Sonar Transducers in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!