How to define RDT function in Matlab?

11 vues (au cours des 30 derniers jours)
Hasantha Dissanayake
Hasantha Dissanayake le 28 Oct 2020
Commenté : Jon le 30 Oct 2020
I used following code for my calculations but I think it has an error.
Code
function [R,t] = RDT(y,ys,T,dt)
%
% [R] = RDT(y,ys,T,dt) returns the free-decay response (R) by
% using the random decrement technique (RDT) to the time serie y, with a
% triggering value ys, and for a duration T
%
% INPUT:
% y: time series of ambient vibrations: vector of size [1xN]
% dt : Time step
% ys: triggering values (ys < max(abs(y)) and here ys~=0)
% T: Duration of subsegments (T<dt*(numel(y)-1))
% OUTPUT:
% R: impusle response function
% t: time vector asociated to R
%
% Author: E. Cheynet - UiB - last modified 14-05-2020
%%
if T>=dt*(numel(y)-1)
error('Error: subsegment length is too large');
else
% number of time step per block
nT = round(T/dt); % sec
end
if ys==0
error('Error: ys must be different from zero')
elseif or(ys >=max(y),ys <=min(y)),
error('Error: ys must verifiy : min(y) < ys < max(y)')
else
% find triggering value
ind=find(diff(y(1:end-nT)>ys)~=0)+1;
end
% construction of decay vibration
R = zeros(numel(ind),nT);
for ii=1:numel(ind)
R(ii,:)=y(ind(ii):ind(ii)+nT-1);
end
% averaging to remove the random part
R = mean(R);
% normalize the R
R = R./R(1);
% time vector corresponding to the R
t = linspace(0,T,numel(R));
end
Error msg
>> RDT
Not enough input arguments.
Error in RDT (line 18)
if T>=dt*(numel(y)-1)
can anybody suggest me a solution for this problem?
Thank You.!
  2 commentaires
Jon
Jon le 28 Oct 2020
You can use the code button on the MATLAB Answers toolbar to nicely format your code.
E. Cheynet
E. Cheynet le 29 Oct 2020
Hi Hasantha,
There is a Matlab livescript on Matlab File Exchange, which shows how to use the function RDT: https://se.mathworks.com/matlabcentral/fileexchange/55557-damping-ratio-estimation-from-ambient-vibrations-sdof?s_tid=srchtitle

Connectez-vous pour commenter.

Réponses (1)

Jon
Jon le 28 Oct 2020
Modifié(e) : Jon le 28 Oct 2020
You need to call the function with its arguments.
You just typed rdt on the command line. You must first assign the variables y,ys, T, and dt and then type on the command line:
R= rdt(y,ys,T,dt)
Note it is not necessary to use the same variable names on the command line as in the function definition, so assuming a,b,c and d were assigned appropriate values you could also call the function using
R= rdt(a,b,c,d)
  1 commentaire
Jon
Jon le 30 Oct 2020
Hi Did this answer your question? If so please accept the answer so that others with a similar question will know that an answer is available.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by