필터 지우기
필터 지우기

How can i add 0 or 1 to an vector?

조회 수: 1 (최근 30일)
Lotte Buser
Lotte Buser 2017년 12월 4일
답변: KL 2017년 12월 4일
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