Problem isolating and finding out a function maximum value
1 次查看(过去 30 天)
显示 更早的评论
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1545272/image.jpeg)
0 个评论
采纳的回答
Pratyush
2023-11-21
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 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!