beginner: writing a function for code

1 visualización (últimos 30 días)
Adrienne
Adrienne el 20 de Mayo de 2014
Comentada: Adrienne el 20 de Mayo de 2014
what would this be in writing a function called "event detection algorithm"
%%2.2 Calculation of Jump Height Data
% make the data positive, set a threshold (including noise) for
% baseline. tnf = total number of frames
% =================================================================
fz = -data(:,1);
fzmin= min(fz);
fzthres= fzmin+5+n; %%sets threshold
to= find(fz<fzthres,1,'first'); %%take-off
td= find(fz(to:end)>fzthres,1,'first'); %%touch-down
td= td+to -1; %%point of landing, global number
tnf= (td-to); %%jumper in the air
tof= (tnf*fr); %%time of flight eq
jh(i,1)=(-g*(tof.^2)/8); %%jump height eq
fzminMN = nanmean(fz(to:td)); %%mean min across time part
fz= fz + abs(fzminMN);

Respuestas (1)

Image Analyst
Image Analyst el 20 de Mayo de 2014
I would call this just "a chunk of code" though some people may use different terminology. Why do you ask?
  4 comentarios
Adrienne
Adrienne el 20 de Mayo de 2014
I was just thinking, about how I could make my code look neater, and I heard someone talk about user functions. I understand the simple ones, but this one wouldn't be simple. I know the end result it jump height (jt)
fz = -data(:,1);
fzmin= min(fz);
fzthres= fzmin+5+n; %%sets threshold
to= find(fz<fzthres,1,'first'); %%take-off
td= find(fz(to:end)>fzthres,1,'first'); %%touchdown
I know this are^^^ all inputs then tof, tnf, and jh are the outputs with jh being the overall desired output but I have no idea of how to put this into a function.
Adrienne
Adrienne el 20 de Mayo de 2014
sorry my internet is dodgy atm!

Iniciar sesión para comentar.

Categorías

Más información sobre Introduction to Installation and Licensing en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by