Median(here it's middle ) of vector/array of every two adjacent values in array (value(i+1)-value(i)).
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi guys!
I've signal called y1 it's sinusoidal and its amplitude is y axis, x's axis is the time in sec.
I have a have a vector(matrics) called t which its size 1x213 , for instance t=[1 2 3 20 100 50 30 32 44 50 90 10 3 4 6 8 9 30 20 2 1 3 ...etc] (integer values)
I want to take every the difference/subtraction between every two values of t and find the middle of that difference , how could I implement that in matlab?
for more clarifications I want to do difference between each two adjacent point in my array t, in other words to do this diff(i)=t(i+1)-t(i) and find middle of each diff(i) (actually it's the middle of the each differences middle(i)=diff(i)/2 );
if we imagine that every the differences are like "lines" , I want to find the middle of each lines(of each subtraction/differences)
could anyone help me how do I implement that in matlab? thanks alot for your assistance!
0 commentaires
Réponses (1)
dpb
le 15 Juil 2020
Not so sure why this would be puzzling...
tm=diff(t)/2;
You have one few differences than elements of t, of course.
8 commentaires
dpb
le 15 Juil 2020
"clarify the input y>0 to function"
I'd suggest you'll learn far more more quickly and retain better if you just try it and see... :)
Then look for "logical indexing" in the documentation to read all about it.
One of most powerful of the MATLAB idioms...
dpb
le 16 Juil 2020
And, btw, note that using the result of a function or an expression as above is functionally no different than having written
tmp=y>0;
repelelm(tmp,repl)
without creating the temporary variable--MATLAB does the requested operation and saves the result behind the scenes until it is no longer needed but doesn't then leave anything in the workspace once the function that used it finishes.
Of course, if one needs the same result more than once, it'll generally be more efficient to make the temporary rather than recompute the same thing two or more times...
Voir également
Catégories
En savoir plus sur Matrices and Arrays dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!