필터 지우기
필터 지우기

Matrix with strings of different sizes

조회 수: 41 (최근 30일)
Ajay Kumar
Ajay Kumar 2012년 3월 6일
댓글: Maria Canon 2021년 4월 18일
Hello, I would like to know if there is anyway of making this work:
tstFeats = ['NB_ACQ'; 'AEC']
I Basically need to have different sized strings in each row of a matrix. Thank you for the help!
  댓글 수: 2
Richard Vasquez
Richard Vasquez 2020년 11월 26일
I'm trying to develop a Lempel-Ziv algorithm. I need to build a dictionary of strings, but the string lenghts are going to vary as it grows.
I think a Cell String will work, but I'm hoping the find function still works with it. If there's a better way to do this, please share?
Thank you, Richard V
Steven Lord
Steven Lord 2020년 11월 26일
When this question was first asked a cell array containing char vectors was the best option.
Now I would use a string array.
a = ["apple"; "banana"; "cantaloupe"; "durian"]
a = 4×1 string array
"apple" "banana" "cantaloupe" "durian"

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

채택된 답변

Jan
Jan 2012년 3월 7일
A matrix is always rectangular.
To get a list of string of different length, use a cell string:
tstFeats = {'NB_ACQ'; 'AEC'}
Consider the curly braces.
  댓글 수: 2
Ajay Kumar
Ajay Kumar 2012년 3월 7일
Thank you so much!
Maria Canon
Maria Canon 2021년 4월 18일
I used this to put a bunch of different string arrays of different sizes into one using the code below:
latinxData = {very_Lfm, very_Lm, vattractive_Lfm, vattractive_Lm, vfemL, vmascL};
This creates a 1x6 cell that links to the different strings. Is there any way to rename what it shows up as to the original variable names?

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by