Calculating an average if specific condition is fulfilled
이전 댓글 표시
Hello everybody,
I am working on my own project right now and needing some help now.
What do I want to do?
Matlab should calculate the average out of values for a specific time period.
time (sec) value
0 2
1 3
2 4
3 6
4 7
5 8
6 2
If time is >0 and smaller or equal to 3 sec Matlab should calculate the arithmetic average of the values.
So basically something like this:
IF 0>=time>=3
Do arithmetic average of value
So the result should be (2+3+4+6 )/4 =3,75.
It is my first project with MatLab and I am usually working with other programms.
Thanks for your help.
Your sincerely,
Max
답변 (1개)
madhan ravi
2019년 5월 6일
편집: madhan ravi
2019년 5월 6일
1 개 추천
https://in.mathworks.com/company/newsletters/articles/matrix-indexing-in-matlab.html - read the topic logical indexing once you understand that use mean() after that process.
I also suggest you to do MATLAB on-ramp course.
댓글 수: 6
Max Behr
2019년 5월 6일
madhan ravi
2019년 5월 7일
https://matlabacademy.mathworks.com - do this course, only takes a couple of hours (so that you don't have to depend on anyone often).
Don't name your variables dynamically see https://in.mathworks.com/matlabcentral/answers/304528-tutorial-why-variables-should-not-be-named-dynamically-eval to know why. Use a cell array for intance:
time=cell(2,1);
time{1}=...
time{2}=...
Max Behr
2019년 5월 7일
madhan ravi
2019년 5월 7일
Experiment and get back.
Max Behr
2019년 5월 7일
madhan ravi
2019년 5월 9일
time=cell(2,1);
time{1} =[ 1 2 3 ]
time{2} =[ 1 2 3 4 5 ]
카테고리
도움말 센터 및 File Exchange에서 MATLAB에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!