필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

can help me with this simple code?

조회 수: 1 (최근 30일)
fede
fede 2016년 3월 23일
마감: MATLAB Answer Bot 2021년 8월 20일
I have a list of string (str_1,str_2.......str_n) an a matrix called "A" of string
str_1 str_2
str_1 str_4
... ...
I want to assign for each "str" a number, for example
str_1=1
str_2=2
....
to have the matrix "A":
1 2
1 4
  댓글 수: 1
Jan
Jan 2016년 3월 23일
"A" cannot be a matrix of strings, because this is not valid in Matlab. Do you mean a cell string?

답변 (2개)

Jan
Jan 2016년 3월 23일

Walter Roberson
Walter Roberson 2016년 3월 23일
If you have the Symbolic Toolbox, you can do this:
str = sym('str_%d', [1 n]);
A = [str(1), str(2)
str(1), str(4)];
subs(A, str, [1 2 17 4])
you might even be able to refer to str_1 directly in A; I would need to test that.

이 질문은 마감되었습니다.

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by