How can I get the min,max, and avg of velocity while showing at what time that I got those values?
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Jason
am 2 Nov. 2014
Kommentiert: Star Strider
am 3 Nov. 2014
So far I got to this point and just cant figure out how to get the time that each of these values are at and display them. I really appreciate any help!
clear;
clc;
veldata = dlmread('veldata.txt',' ');
time = veldata(:,1);
velocity = veldata(:,2);
[min_velocity,2] = min(velocity);
[max_velocity,2] = max(velocity);
[avg_velocity, 2] = mean(velocity);
0 Kommentare
Akzeptierte Antwort
Star Strider
am 2 Nov. 2014
I can’t run your code, but you can take advantage of the max and min functions also returning the index of the vector at those values:
[min_velocity,minidx] = min(velocity);
[max_velocity,maxidx] = max(velocity);
avg_velocity = mean(velocity);
avgidx = find(velocity <= avg_velocity,1,'last');
Since the mean may not equal any element in the vector, getting the last element less than or equal to the mean is likely as good as it gets.
To get the times at those values, reference them by index:
t_minv = time(minidx);
t_maxv = time(maxidx);
t_avgv = time(avgidx);
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Systems of Nonlinear Equations 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!