- 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 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Image Analyst
le 31 Juil 2018
Lots of errors.
etc. Make another shot at it after those corrections are made and we'll try again.
2 commentaires
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!