Problem isolating and finding out a function maximum value

조회 수: 4 (최근 30일)
Lucas Resende
Lucas Resende 2023년 11월 21일
답변: Pratyush 2023년 11월 21일
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

채택된 답변

Pratyush
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개)

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

태그

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by