Effacer les filtres
Effacer les filtres

How can i add 0 or 1 to an vector?

1 vue (au cours des 30 derniers jours)
Lotte Buser
Lotte Buser le 4 Déc 2017
Réponse apportée : KL le 4 Déc 2017
I have to compare the numbers in Pos white the numbers in pos like 30 is greater then 31, then i have to add a number 1 to a new_vector if it's smaller then the previous number i have to add a number 0 te the new_vector
new_vector[]
Pos = [30 31 33 35 38 36 34 32 30 28 26 24 22 22 23 24];
  1 commentaire
Jan
Jan le 4 Déc 2017
Modifié(e) : Jan le 4 Déc 2017
Your chances to get an answer will grow, if you write it in English.
All I understand are the 3 code lines, but the "close all" is suspicious: It seems like you want to manipulate a vector, so why does closing all figure matters here? I assume it is the typical "cargo cult programming", in which every piece of code starts with the brutal clearing of everything: "clear all; close all; clc".

Connectez-vous pour commenter.

Réponse acceptée

KL
KL le 4 Déc 2017
use diff,
new_vector = [0 diff(Pos)>0]
the answer is
0 1 1 1 1 0 0 0 0 0 0 0 0 0 1 1

Plus de réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by