How can I increase my vector by increments of 100 but end on 558?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Clare Ferguson
le 24 Sep 2017
Modifié(e) : Stephen23
le 24 Sep 2017
I need to create a vector that starts at 0, increases by 100 each time but ends at 558.
The following outlines my function:
x_int = 0:100:558
This works except it only calculates up to 500 and not 558.
1 commentaire
Réponse acceptée
Stephen23
le 24 Sep 2017
Modifié(e) : Stephen23
le 24 Sep 2017
Like this?:
>> val = 558;
>> vec = 0:100:val;
>> vec = [vec,val(vec(end)~=val)]
vec =
0 100 200 300 400 500 558
Doing this over two lines allows appending that value only if it is not already the last value in the vector, e.g.:
>> val = 500;
>> vec = 0:100:val;
>> vec = [vec,val(vec(end)~=val)]
vec =
0 100 200 300 400 500
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Interpolation 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!