Changing a .GAMBL file to a .MAT file

조회 수: 5 (최근 30일)
Kbar
Kbar 2022년 6월 7일
댓글: Image Analyst 2022년 6월 7일
hello,
So I am trying to use a code someone wrote to find an integral of angular velocity and I tried to just switch my file out for theirs and run it but my file won't work because it is a .GAMBL file.
^ that is the file.
I am super new to this but love engineering and I need this to help with my physics project on boat stability.
D = load('barge1.gambl');
AngularVelocity = D.AngularVelocity;
tv = AngularVelocity.time;
pv = AngularVelocity.x;
qv = AngularVelocity.y;
figure
plot(tv, pv)
grid
% Ts = mean(diff(tv));
% Fs = 1/Ts;
[pn,~] = resample(pv, tv, 125); % Resample To Constant Sampling Interval
[qn,tn] = resample(qv, tv, 125); % Resample To Constant Sampling Interval
Fs = 125; % Sampling Frequency
Fn = Fs/2; % Nyquist Frequency
L = numel(tn); % Signal Length
FTpn = fft(pn)/L; % Normalised Fourier Transform
Fv = linspace(0, 1, fix(L/2)+1)*Fn; % Frequency Vector
Iv = 1:numel(Fv); % Index Vector
figure
plot(Fv, abs(FTpn(Iv))*2)
grid
xlim([0 5])
Wp = 0.20/Fn; % Passband Frequency (Normalised)
Ws = 0.50/Fn; % Stopband Frequency (Normalised)
Rp = 1; % Passband Ripple
Rs = 60; % Passband Ripple (Attenuation)
[n,Wp] = ellipord(Wp,Ws,Rp,Rs); % Elliptic Order Calculation
[z,p,k] = ellip(n,Rp,Rs,Wp,'high'); % Elliptic Filter Design: Zero-Pole-Gain
[sos,g] = zp2sos(z,p,k); % Second-Order Section For Stability
figure
freqz(sos, 2^16, Fs) % Filter Bode Plot
pn_filt = filtfilt(sos,g, pn); % Filter ‘p’
qn_filt = filtfilt(sos,g, qn); % Filter ‘q’
figure
plot(tn, pn_filt)
hold on
plot(tv, pv)
hold off
grid
roll = cumtrapz(tn,pn_filt);
pitch = cumtrapz(tn,qn_filt);
figure
plot(tn,pn_filt)
hold on
plot(tn,roll)
legend('p','roll')
figure
plot(tn,qn_filt)
hold on
plot(tn,pitch)
legend('q','pitch')
  댓글 수: 1
Image Analyst
Image Analyst 2022년 6월 7일
Zip up your file and then attach the zip file here with the paperclip icon after you read this:

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Spectral Measurements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by