probability of exceedance contour
18 views (last 30 days)
Show older comments
Dear All,
I am working on current analysis using long-term data. I would like to plot the exceedance probabilty for current speed, using current speed for x, depth for y and exceedance probability for z. Please find attrached the example current speed data on excelsheet and probability of exceedance of current velocities graph i want to create. The first row shows the depth and the other rows show the current velocities of those depths. I tried to compute z values using eprob function, found mathworks, but contourf command does not accept this value since it is a vector and not a matrix. Do you have any idea how to go from the shared data to the example graph that I have?
Thank in advance!
0 Comments
Answers (1)
Divyam
on 17 Sep 2024
The data in the "test.xlsx" file has some NaN values and hence might result in issues during the calculation of the exceedence probability so you can choose to remove it.
To calculate exceedence probability for each depth you should first fetch the current speeds for each depth and then use the "eprob" function on the current speeds. The output of the "eprob" structure will return a struct which contains the "eprob" field name which when accessed, returns the exceedence probability of that data. You can then plot the exceedence probabilities using the "meshgrid" and "contourf" function.
% Load data from Excel
data = readmatrix('test.xlsx');
% Optional: If you wish to remove the rows with NaNs
cleaned_data = rmmissing(data, 'MinNumMissing', 1);
% Replace data with cleaned_data in the optional scenario
depths = data(1, 2:end);
current_speeds = data(2:end, 2:end);
%Initialize matrix for exceedance probabilities
exceedance_probs = zeros(size(current_speeds));
% Calculate exceedance probability for each depth
for i = 1:length(depths)
speeds = current_speeds(:, i);
output = eprob(speeds);
exceedance_probs(:, i) = output.eprob; % Exceedance probability
end
% Prepare data for contour plot
[X, Y] = meshgrid(1:size(current_speeds, 1), depths);
% Plot
figure;
contourf(X, Y, exceedance_probs', 'LineStyle', 'none');
colorbar;
xlabel('Current Speed Index');
ylabel('Depth');
title('Exceedance Probability of Current Velocities');
For more information regarding the "meshgrid" and "contourf" functions, refer to the following documentations:
0 Comments
See Also
Categories
Find more on Contour 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!