errore too many output
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Quando eseguo lo script fino al plot delle due prime figure funziona, per la parte che segue riguardante la funzione fft mi da errore: " Error using fft Too many output arguments.", come risolvo?
close all
format longE
clear
clc
%definition of the file path
data_folder_path= 'l2_CFRP/';
file='l2_CFRP.txt';
file_path= strcat(data_folder_path, file);
%load data
% column 1: sampling period [mV]
% column 2: time between samples
% column 3: acceleration z-axis [mV/m/s^2]
% column 4: displacement z-axis [mV/ms/^2]
accelerometer = readmatrix(file_path);
%time vector
N=size(accelerometer,1);
samples= accelerometer (:,1);
time= accelerometer(:,2)*10^4;
acc_z = accelerometer(:,3);
displacement = accelerometer (:,4);
dt= round(time(2)-time(1),2);
%sampling frequency
for n= 1:738
fs(n)=n/dt;
end
fs(n)=n/dt;
disp('sampling frequency:');
disp(fs(n));
figure
plot( time, acc_z)
xlabel('time')
ylabel('acc_z [m/s^2]')
xlim ([0,samples(end)])
grid
figure
plot( time, displacement)
xlabel('time')
ylabel('displacement')
xlim ([0,samples(end)])
grid
%FFT
[norm_sp,f_vector]=fft(acc_z,fs(n));
figure
plot(f_vector,abs(acc_z), LineWidt=1.5)
xlim([0,f_vector(end)])
xlabel('Frequency [Hz]')
ylabel('amplitude [m/s^]')
grid
figure
semilogy(f_vector, abs(acc_z))
xlim([0,f_vector(end)])
xlabel('Frequency [Hz]')
ylabel('amplitude [m/s^]')
grid
function [norm_sp, freq_vec]=fft_n(acc_z,fs)
dim=size(l2_CFRP);
if dim(2)>dim(1)
'l2_CFRP=l2_CFRP';
end
N=length(l2_CFRP.txt);
df=fs/N;
end
0 commentaires
Réponses (1)
Les Beckham
le 3 Août 2023
You are trying to do this
[norm_sp,f_vector]=fft(acc_z,fs(n));
Y = fft(X)
Y = fft(X,n)
Y = fft(X,n,dim)
3 commentaires
Les Beckham
le 3 Août 2023
Comment translation:
I have data in the time domain and I need to transform them and read them in the frequency domain. in order to have the maximum peaks of my oscillations in relation to the frequency and no longer to the time.
Response:
Yes, and that is a good reason to use the fft function. You need to use it in accordance with its documentation, however. It will not work if you try to get it to return information that it was not designed to -provide. Read the documentation.
I suggest that, in addition to reading the documentation, you read this answer, by an excellent contributor to Matlab Answers, to a previous question: https://www.mathworks.com/matlabcentral/answers/460152-fft-for-the-given-data-to-find-the-dominant-frequency#answer_373524
You should be able to adapt that to your problem.
Response translation:
Sì, e questo è un buon motivo per usare la funzione fft. Tuttavia, è necessario utilizzarlo in conformità con la sua documentazione. Non funzionerà se provi a fargli restituire informazioni che non è stato progettato per fornire. Leggi la documentazione. Suggerisco che, oltre a leggere la documentazione, leggi questa risposta, di un eccellente collaboratore di Matlab Answers, a una domanda precedente:
Dovresti essere in grado di adattarlo al tuo problema.
Buona fortuna.
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!