Changing a .GAMBL file to a .MAT file
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commento
Image Analyst
il 7 Giu 2022
Zip up your file and then attach the zip file here with the paperclip icon after you read this:
Risposte (0)
Vedere anche
Categorie
Scopri di più su Spectral Measurements in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!