Putting two FAS figures into one.
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello,
I am running fourier transform function for two datasets. The script below create two figures and I wonder how to modify to put both in a one plot.
Thanks in advance for any help.
Cheers,
Anna
% load recorded nodal data
acc = load ('/Users/annakowal/Documents/2D_site_analysis/flow_Hamilton/Taieri_2Dprofile/TEST11.out');
acc2 = load ('/Users/annakowal/Documents/2D_site_analysis/flow_Hamilton/Taieri_2Dprofile/TEST12.out');
time = acc(:,1);
time2 = acc2(:,1);
% remove time column from data
acc(:,1) = [];
acc2(:,1) = [];
% data descriptors
[nStep, nAcc] = size(acc);
nDOF = 2;
nNode = nAcc/nDOF;
[nStep2, nAcc2] = size(acc2);
nDOF2 = 2;
nNode2 = nAcc2/nDOF2;
% reshape data
a = reshape(acc, nStep, nDOF, nNode)/9.80665;
a2 = reshape(acc2, nStep2, nDOF2, nNode2)/9.80665;
dt=0.005; %time step
% FOURIER AMPLITUDE SPECTRUM
[f,U]=FAS(dt,a);
param.FAS = U;
param.freq = f;
[f,U]=FAS(dt,a2);
param.FAS = U;
param.freq = f;
function[f,U]=FAS(dt,a)
Ny = (1/dt)/2; %Nyquist frequency (highest frequency)
L = length(a); %number of points in acc
NFFT = 2^nextpow2(L); % Next power of 2 from length of acc
df = 1/(NFFT*dt); %frequency spacing
U = abs(fft(a,NFFT))*dt; %Fourier amplitudes
U = U(2:Ny/df+1); %single sided FAS
f = linspace(df,Ny,Ny/df)'; %[small, large, number] frequencies
figure;
plot(f,U,'-r','linewidth',1.5)
grid on
box on
xlabel('Frequency (Hz)','fontsize',16)
ylabel('Fourier Spectral Acceleration (g)','fontsize',16)
legend ('Fourier Amplitude Spectrum')
axis([0 10 -inf inf])
return
end
0 Kommentare
Antworten (2)
Star Strider
am 4 Mär. 2021
Example —
figure
plot(x1, y1)
hold on
plot(x2, y2)
plot(x3, y3)
hold off
grid
.
0 Kommentare
Walter Roberson
am 5 Mär. 2021
Bearbeitet: Walter Roberson
am 5 Mär. 2021
Remove the call
figure;
Add the call
hold on
after the plotting
0 Kommentare
Siehe auch
Kategorien
Mehr zu Specifying Target for Graphics Output finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!