How can i add 0 or 1 to an vector?

1 次查看(过去 30 天)
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 个评论
Jan
Jan 2017-12-4
编辑:Jan 2017-12-4
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".

请先登录,再进行评论。

采纳的回答

KL
KL 2017-12-4
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Axis Labels 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by