Function to find vertex of graph?

11 views (last 30 days)
Jungil
Jungil on 23 Apr 2023
Commented: Jungil on 23 Apr 2023
clear; clc;
m = 2.5; % kg
k = 6e6; % N/m
c = 180; % N-s/m
r = 0:0.01:2;
Wn = sqrt(k/m) % rad/s
zeta = c / (2*sqrt(k*m))
omega = r * Wn;
imag1 = 1/k*(-2*zeta*r)./((1-r.^2).^2 + (2*zeta*r).^2);
figure(1)
plot (omega/(2*pi), imag1, 'k-') % r -> hz
xlabel('Frequency (Hz)')
ylabel('Im(G(W)) (m/N)')
grid on
I want to make a code that can find the x-coordinate and y-coordinate positions of the vertices at the bottom of the plot in the graph.

Accepted Answer

Dyuman Joshi
Dyuman Joshi on 23 Apr 2023
m = 2.5; % kg
k = 6e6; % N/m
c = 180; % N-s/m
r = 0:0.01:2;
Wn = sqrt(k/m); % rad/s
zeta = c / (2*sqrt(k*m));
omega = (r * Wn)/(2*pi);
imag1 = 1/k*(-2*zeta*r)./((1-r.^2).^2 + (2*zeta*r).^2);
%Y Position of the vertex, i.e. Global minima
[ymin,idx] = min(imag1)
ymin = -3.5861e-06
idx = 101
%Corresponding x value
xmin = omega(idx)
xmin = 246.5618
figure(1)
plot (omega, imag1, 'k-') % r -> hz
xlabel('Frequency (Hz)')
ylabel('Im(G(W)) (m/N)')
grid on
hold on
%plotting the vertex
plot(xmin,ymin,'r*')

More Answers (0)

Categories

Find more on Display Image in Help Center and File Exchange

Tags

Products


Release

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!