How to find the gradient of plotted values?
20 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
So, I'm trying to find the rate of climb against the velocity.
Both of these variables are 1 x 100 vectors.
rate of climb = v.*(T-D)./w
where w is a constant. t,d and v are all arrays of 1 x 100 row vectors. I was wondering ways to find the derivative at the local maximum. Examples would be appreciated.
0 Commenti
Risposte (3)
madhan ravi
il 4 Gen 2024
Modificato: madhan ravi
il 4 Gen 2024
Derivative at the local maximum is zero.
You could find the gradient of a variable using
doc gradient
0 Commenti
Star Strider
il 4 Gen 2024
Fs = 100;
L = 60;
t = linspace(0, Fs*L, Fs*L+1)/Fs; % Time Vector
s = sin(2*pi*t/10) .* exp(-(t-30).^2*0.01); % Signal Vector
dsdt = gradient(s, t); % Gradient (Derivative)
figure
plot(t, s, 'DisplayName','Signal')
hold on
plot(t, dsdt, 'DisplayName','Derivative')
hold off
grid
legend('Location','best')
.
0 Commenti
Hassaan
il 5 Gen 2024
% Dummy values for T, D, and v
w = 5000; % Constant weight
v = linspace(100, 300, 100); % Velocity vector ranging from 100 to 300 m/s
T = 2000 + 100 * cos(linspace(0, 2*pi, 100)); % Thrust vector as a function of v
D = 1500 + 50 * sin(linspace(0, 2*pi, 100)); % Drag vector as a function of v
% Calculate the rate of climb
rate_of_climb = v .* (T - D) / w;
% Find the local maxima of the rate of climb
[peaks, locs] = findpeaks(rate_of_climb);
% Assuming uniform spacing in your velocity vector
% Calculate the numerical derivative using the gradient function
dv = mean(diff(v)); % The mean difference between velocity points
derivative_roc = gradient(rate_of_climb, dv);
% Find the derivative at the local maxima
derivative_at_maxima = derivative_roc(locs);
% Display the results
disp('Velocity at local maxima:');
disp(v(locs));
disp('Rate of climb at local maxima:');
disp(peaks);
disp('Derivative of rate of climb at local maxima:');
disp(derivative_at_maxima);
% For visualization, plot the rate of climb and mark the local maxima
figure;
plot(v, rate_of_climb);
hold on;
plot(v(locs), peaks, 'ro');
xlabel('Velocity (m/s)');
ylabel('Rate of Climb (m/s)');
title('Rate of Climb vs. Velocity');
legend('Rate of Climb', 'Local Maxima');
grid on;
hold off;
rate_of_climb is calculated using the given formula.
findpeaks is used to locate the local maxima in the rate of climb.
gradient function is used to numerically approximate the derivative of the rate of climb with respect to velocity.
------------------------------------------------------------------------------------------------------------------------------------------------
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.
Professional Interests
- Technical Services and Consulting
- Embedded Systems | Firmware Developement | Simulations
- Electrical and Electronics Engineering
0 Commenti
Vedere anche
Categorie
Scopri di più su Spectral Measurements 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!