필터 지우기
필터 지우기

Convert a numeric vector to 1-D cell of strings

조회 수: 2 (최근 30일)
bethel o
bethel o 2023년 3월 31일
댓글: bethel o 2023년 4월 4일
How can one convert a numeric vector to 1-D cell of strings in a in one line without a loop and user defined lamda?
So convert
numbers=[1,2];
to
numbers_dropdown_item={'1','2'}.
A use case is with the accepted value for uidropdown.Items

채택된 답변

Dyuman Joshi
Dyuman Joshi 2023년 3월 31일
nums=[1,2,12,121];
out=cellstr(string(nums))
out = 1×4 cell array
{'1'} {'2'} {'12'} {'121'}
  댓글 수: 3
Dyuman Joshi
Dyuman Joshi 2023년 3월 31일
How is that incorrect? And what is the expected output then?
bethel o
bethel o 2023년 4월 4일
Shouldn't ask the question in the first place had I understood matlab's interesting display.
Apparently: {'1','2'} == {'1'} {'2'} ~= {{'1'}{'2'}} but they are all 1×2 cell array.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

태그

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by