필터 지우기
필터 지우기

Question on how to code something

조회 수: 3 (최근 30일)
Lucas
Lucas 2014년 1월 24일
댓글: Lucas 2014년 1월 25일
Hi all,
My program produces two vectors which indicate current over time:
t_vec = [25 33 58 100]
I_vec = [50 0 -50 0]
which means that the current is 50 on the time interval [0,25], current 0 on [25,33] etc.
Now I want to extend both vectors so they give the current at every multiple of 10 sec as well:
T_vec = [0 10 20 25 30 33 40 50 58 60 70 80 90 100]
This T_vec I managed to make with "sort(0:10:100,T_vec)" , but the corresponding current vector
I_vec = [50 50 50 50 0 0 -50 -50 -50 0 0 0 0 0]
is more difficult to produce. Any suggestions? Thanks in advance!
Lucas
  댓글 수: 1
Walter Roberson
Walter Roberson 2014년 1월 24일
? You cannot use two numeric vectors as input to sort() ?

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2014년 1월 24일
[counts, bins] = histc( T_vec, t_vec );
expanded_I_vec = I_vec(bins);
  댓글 수: 1
Lucas
Lucas 2014년 1월 25일
Thank you, the histc command was what I was looking for.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Colormaps에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by