Effacer les filtres
Effacer les filtres

How generate a sea state wave heights (Hs) random number for each bin (time interval-Tp)? I did use lognormal distribution.

4 vues (au cours des 30 derniers jours)
bin1 = lognrnd(m1.mu1,standarddeviation.mu1,631604,1); %mu = 0.3149, sigma = 0.173;
bin2 = lognrnd(m1.mu2,standarddeviation.mu2,631604,1); %mu = 0.630, sigma = 0.361;
bin3 = lognrnd(m1.mu3,standarddeviation.mu3,631604,1); %mu = 1.095, sigma = 0.519;
%The number 6316004 is the total generated numbers (n) for each bin, I whish it to be random (diferente from one bin to another).
%I am considering long-term sea state, where most of the Hs are ripples (ranging in between [0, 12] m). Rhey are rare for heights of 6+ m.

Réponses (1)

Krishna
Krishna le 24 Nov 2023
Hello Jose,
It seems like you are generating random wave heights (Hs) for different time intervals (bins) using the lognormal distribution in MATLAB. However, you wish to make the total number of generated numbers (n) random for each bin. Additionally, you've mentioned that for long-term sea states, most of the Hs are ripples ranging between 0 and 12 meters, and heights of 6+ meters are rare.
To address your requirements, you can generate a random number of samples for each bin and then generate the wave heights using the lognormal distribution. Here's how you can achieve this:
m1.mu1 = 0.3149; standarddeviation.mu1 = 0.173;
m1.mu2 = 0.630; standarddeviation.mu2 = 0.361;
m1.mu3 = 1.095; standarddeviation.mu3 = 0.519;
% Generate a random number of samples for each bin
numSamples = randi([x1 x2], 1, 3);
% where x1 and x2 is the range you want your number of samples to be in.
% Generate a random number of samples for each bin
% Generate random wave heights for each bin
bin1 = lognrnd(m1.mu1, standarddeviation.mu1, numSamples(1), 1);
bin2 = lognrnd(m1.mu2, standarddeviation.mu2, numSamples(2), 1);
bin3 = lognrnd(m1.mu3, standarddeviation.mu3, numSamples(3), 1);
To make sure Hs lies between 0 and 12 meters you can use min max function. For eg:
bin1 = max(0, min(bin1, 12));
Also please have a look at this document for more information regaring lognrnd function.
Hope this helps.

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by