フィルターのクリア

How to plot upper and lower bounds in graph with 95% confidence.

4 ビュー (過去 30 日間)
AL
AL 2023 年 4 月 21 日
回答済み: Walter Roberson 2023 年 4 月 21 日
% preallocate output variables
n_files = 2;
Time = cell(n_files, 1);
Veloc = cell(n_files, 1);
Ypk_plot = cell(n_files, 1);
Xpk_plot = cell(n_files, 1);
Y = cell(n_files, 1);
X = cell(n_files, 1);
P = cell(n_files, 1);
damp_ratio = zeros(1, n_files);
wd = zeros(1, n_files);
wn = zeros(1, n_files);
K_ex = zeros(1, n_files);
% read Data from files and process each file
for j = 1:n_files
% read Data from file
z1 = importdata("Xxsv0000"+num2str(j)+".txt");
% extract time and velocity Data
Time{j} = z1.data(:,1);
Veloc{j} = z1.data(:,2);
% find local maxima in velocity Data within the range of indices
[Ypk, Xpk] = findpeaks(Veloc{j}(1:550));
Ypk_plot{j} = Ypk(11:35);
Xpk_plot{j} = Xpk(11:35);
Y{j} = Ypk;
X{j} = Xpk;
P{j} = zeros(size(Ypk));
% plot Data against time Data and mark the locations of the peaks found
figure
plot(Time{j}, Veloc{j}, 'DisplayName', 'Data')
hold on
plot(Time{j}(Xpk_plot{j}), Ypk_plot{j}, 'dr', 'DisplayName', 'Pick points')
grid on
legend('Data','Pick Points','FontSize',12)
xlabel('Time','FontSize',12)
ylabel("Voltage (V/V)",'FontSize',12)
sgtitle(['K', num2str(j)])
% calculate logarithmic decrement, damping ratio, and natural frequency
t_new = Time{j}(X{j});
y_new = Y{j};
Log_Dec = abs(log(y_new(1:end-1) ./ y_new(2:end)));
Mean_dec = mean(Log_Dec);
Damp_period = (t_new(end) - t_new(1)) / length(t_new);
wd(j) = 2*pi / Damp_period;
damp_ratio(j) = Mean_dec / sqrt((2*pi)^2 + Mean_dec^2);
wn(j) = wd(j) * sqrt(1 - damp_ratio(j)^2);
% calculate spring constant
K_ex(1,j) = m_for_k(1,j) * wn(1,j)^2;
end
clear j n_files t_new Time Veloc X Xpk Xpk_plot Y;
clear y_new Ypk_plot z1 Damp_period Log_Dec Mean_dec Ypk P;

回答 (1 件)

Walter Roberson
Walter Roberson 2023 年 4 月 21 日
For this type of task, plotting 95% confidence, a common technique is to take the standard deviation std and use norminv to find the 2.5% and 97.5% probability levels for that mean and standard deviation, and plot those

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by