How to find the peak values from simulink file(.slx) in matlab coding. I'm getting pks = 0×1 empty double column vector, locs = 0×1 empty double column vector errors.

1 回表示 (過去 30 日間)
The file .slx file is attatched below
  2 件のコメント
Mathieu NOE
Mathieu NOE 2021 年 11 月 8 日
hello
I could not do the sim because I lack some toolboxes
can you save your simulation outputs to a mat file ?
Mathieu NOE
Mathieu NOE 2021 年 11 月 15 日
hello
as I said before , I cannot work from your sim because i don't have the library 'powerlib'
I could only help you if you could share the results of sim, saved in a mat file
tx

サインインしてコメントする。

採用された回答

Mathieu NOE
Mathieu NOE 2021 年 11 月 16 日
hello
so the issue is to plot the max of your data (once taken the absoute value of it) . In this case findpeaks is overkill, a simple max is enough to find the point and plot it
NB : the code works for a max positive or negative value
load('all_components_values_matlab.mat');
t = Inrushcurrent.Time;
Inrushcurrent = Inrushcurrent.Data ;
plot(t,Inrushcurrent);
title('Inrush current at 0 degrees switching angle')
ylabel('Inrush current [A]')
xlabel('Time [s]')
grid on
hold on
%Finding the peak (max of absolute value) values of inrush current (positive or negative)
[~,locs] = max(abs(Inrushcurrent));
t_peak = t(locs);
Inrushcurrent_peak = Inrushcurrent(locs);
plot(t_peak,Inrushcurrent_peak,'dr');
text(t_peak+0.05,Inrushcurrent_peak,['Inrush current = ' num2str(Inrushcurrent_peak) ' A']);
  3 件のコメント
Mathieu NOE
Mathieu NOE 2021 年 11 月 19 日
hello
sorry but again the slx file will not help me
can your share again the data as at file ?
tx
Mathieu NOE
Mathieu NOE 2021 年 11 月 19 日
sorry there was a typo in my last answer
can you share again the data as mat file ?

サインインしてコメントする。

その他の回答 (1 件)

Mathieu NOE
Mathieu NOE 2021 年 11 月 19 日
hello again
so this is the improved version of my code
I also rounded the peak values numbers displayed in the plot
load('all_components_values_matlab.mat');
[samples,phases] = size(Inrushcurrent);
%Finding the peak (max of absolute value) values of inrush current (positive or negative)
figure(1)
title('Inrush current at 0 degrees switching angle')
for ci = 1:phases
[~,locs] = max(abs(Inrushcurrent(:,ci)));
t_peak(ci) = t(locs);
Inrushcurrent_peak(ci) = round(Inrushcurrent(locs,ci));
subplot(phases,1,ci),plot(t,Inrushcurrent(:,ci),t_peak,Inrushcurrent_peak(ci),'dr');
text(t_peak(ci)*1.05,0.85*Inrushcurrent_peak(ci),['Inrush current = ' num2str(Inrushcurrent_peak(ci)) ' A']);
end
ylabel('Inrush current [A]')
xlabel('Time [s]')
  7 件のコメント

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeDescriptive Statistics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by