Problem isolating and finding out a function maximum value
1 view (last 30 days)
Show older comments
Hello there. So, I'm having trouble trying to isolate three different functions and obtaining their maximum value. Bellow follows the script I've written, and the graph plotted with the functions I want to obtain the maximum amplitude (functions h, alpha, beta). I tried using Max(abs), but it did not work.
(A lot of lines before this)
% Nonlinear time-varying natural frequencies
omega=abs(compeigs(1:2:end,:));
% Nonlinear time-varying damping ratios
zeta=-real(compeigs(1:2:end,:))./omega;
figure(101)
h=plot(ti(tirange),omega/2/pi,ti(tirange([1 end])),[omega_lin omega_lin]/2/pi,'k--','linewidth',lw,'markersize',ms);
set(get(h(1),'parent'),'fontsize',fs);
xlabel('$t$ (s)')
ylabel('$\omega_n(t_0)$')
legend(h(1:4),{'$h$','$\alpha$','$\beta$','Linear'},'interpreter','latex')
xlim(ti(tirange([1 end])))
grid
figure(102)
h=plot(ti(tirange),zeta,ti(tirange([1 end])),[zeta_lin zeta_lin],'k--','linewidth',lw,'markersize',ms);
set(get(h(1),'parent'),'fontsize',fs);
xlabel('$t$')
ylabel('$\zeta(t_0)$')
legend(h(1:4),{'$h$','$\alpha$','$\beta$','Linear'},'interpreter','latex')
xlim(ti(tirange([1 end])))
grid
0 Comments
Accepted Answer
Pratyush
on 21 Nov 2023
Hi Lucas,
I understand that you want to obtain the maximum amplitude of the functions you have ploted.
You could extract the values of the functions h, alpha, and beta where they are being defined in your code. After extracting the function values, you can use the "max" function in MATLAB to find the maximum value of each function.
Here's an example of how you might extract the function values and find their maximum values:
% Extracting function values
h_values = omega/2/pi; % Assuming omega/2/pi represents the function h
alpha_values = ...; % Extract values for the function alpha
beta_values = ...; % Extract values for the function beta
% Finding maximum values
max_h = max(abs(h_values));
max_alpha = max(abs(alpha_values));
max_beta = max(abs(beta_values));
Hope this helps.
0 Comments
More Answers (0)
See Also
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!