- Don't use time as a variable name because it's a built-in function.
- Don't use square brackets like you have done.
- You need to define t and v.
- Make sure that t+1 never exceeds the length of v.
- Setting v to a scalar of 4 will cause the next iteration to bomb because you're trying to access the t'th element of an array, and it's no longer an array - it's a scalar.
- No need to use a semicolon at the end of an if statement.
- You can't use Then - this is MATLAB, not Visual Basic.
- You declare vector but never use it.
How can i convert a vector (1 by 300) into time points
조회 수: 2 (최근 30일)
이전 댓글 표시
I have a 1 by 300 vector. I want to convert it to time points and write a program such that the system will read the cumulative sum from the first point to the current point and output a value if the sum is higher than a specified threshold. If not higher, it will continue to add up the values at the time points. i have written some code below but it is not giving me what I want.
time=1:300;
[vector]=v(t)
for time=1:300
if [v(t)] < 0; Then
[v]= 0; % set the value of threshold
end
if v(t) + v(t+1) >= 1; Then
[v]= 4; % set the value of the threshold
% note the time of increment
end
end
댓글 수: 0
답변 (1개)
Image Analyst
2018년 7월 31일
Lots of errors.
etc. Make another shot at it after those corrections are made and we'll try again.
댓글 수: 2
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!