Multi-step coding to model wave data based on pressure--partially figured out
이전 댓글 표시
Hello! I am very new to Matlab and have been attempting to create a code to model wave data based on pressure data but I have not been very successful at getting through it. I was luckily given a 20 Step workflow for Matlab by the company who created the sensor but I have been failing at correctly coding it to work in Matlab R2018a. Some of the workflow makes no sense to me and I am hoping that some of you who are experts may be able to discern what the code needs to be for a given step. I think much of what I have done is also not correct. Here is the workflow:
- Find the linear regression of the burst data.
- Find the “mean depth”
- Remove mean depth and detrend the burst data
- Apply a Hanning window on the burst data (window size 96 samples) to provide hdata
- Apply a 1D real-only DFT on hdata to provide fdata
- Find max frequency in fdata, which is either the largest frequency or the largest frequency that can be detected without aliasing (Nyquist)
- Remove frequencies higher than max frequency and conjugate aliases in fdata
- Apply attenuation-correction to each frequency in fdata
- Determine principle frequency
- IDFT fdata to provide ifdata
- Inverse the Hanning window on ifdata to provide ihdata
- The rest is based on ihdata:
- Variance (see below).
- Energy = variance * gravity * density * 1000.0
- Statistics are calculated by determining negative-to-positive zero crossings, ignoring the first partial wave (and dropping last partial wave).
- Average period = sum(periods) / n
- Average height = sum(heights) / n
- Rank sort waves by height
- Determine max height, and max period
- Significant height and period are calculated on the largest 1/3 of the waves.
- 1/10 height and period are calculated on the largest 1/10 of the waves.
Default gravity value = 9.780318.
Default density value = 1.0281
Variance = 1/2 A^2 (m^4)
Wave energy = Variance (m^4) * gravity (m/s^2) * density (g/cm^3) * 1000 (Kg * cm^3 / g * m^3)
My actual dataset is over 330,000,000 row txt file and I have attached a 1,000 sample.txt Between help through the community and Matlab tutorials, I've been able to piece together the following but I'm not sure its correct in the larger context. Steps 4-11 are definitely confusing to me and I do not understand. Any help would be greatly appreciated!
Clm = ('sample.txt');
t = readtable(Clm); % t table
y = t{:,4}; % Step 1 linear regression of pressure and depth
x=t{:,2};
b1 = x\y
yCalc1 = b1*x;
scatter(x,y)
hold on
plot(x,yCalc1) % Got a successful-looking graph
xlabel('Pressure')
ylabel('Depth')
title('Pressure vs Depth')
grid on
X = [ones(length(x),1) x]; % Determine linear regression formula y = ax + b
b = X\y
M = mean(y) % Step 2 Mean of Depth
detrend_t2 = detrend(t{:,2}); % Step 3 Detrend Pressure. Can this be done to the entire table or only per column?
trend2 = t{:,2} - detrend_t2;
detrend_t4 = detrend(t{:,4}); % Step 3 Detrend Depth. How to "remove mean depth"?
trend4 = t{:,4} - detrend_t4;
L = 96 % Apply Hann Window of 96 Samples. Did this actually work on the table or just on the variable? Should this be applied to the entire table?
Hs = trend2.*hann(L);
wvtool(Hs);
wininfo = info(Hs)
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!