concatenate column values in a vector
조회 수: 1 (최근 30일)
이전 댓글 표시
i have a vector
v1 = [ 1,0,1,0] (dim 1x4 double)
i wanted to join the values in v1 to a new variable
v2 = [1010] (dim 1x1 double)
how to do so
댓글 수: 0
채택된 답변
KALYAN ACHARJYA
2019년 11월 20일
편집: KALYAN ACHARJYA
2019년 11월 20일
Simpler way:
v=[1,0,1,0];
result=str2num(sprintf('%1d',v))
Result:
result =
1010
>>
댓글 수: 0
추가 답변 (2개)
Erivelton Gualter
2019년 11월 20일
You can use the following line of code:
v2 = sum(v1*diag(10.^(length(v1)-1:-1:0)));
댓글 수: 0
Steven Lord
2019년 11월 20일
Treat v1 as the coefficients of a polynomial and evaluate that polynomial for x = 10.
v1 = [ 1,0,1,0];
v2 = polyval(v1, 10)
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Polynomials에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!