Passing information between arrays

name3d = [1x31 char] [1x31 char] [1x31 char]
ct = 1
for i = 1:length(name3d)
tableName{ct} = name3d(i)
ct = ct + 1;
end
This code results in:
tableName = {1x1 cell} {1x1 cell} {1x1 cell}
What I want is:
tableName = [1x31 char] [1x31 char] [1x31 char]
The intent here is to take an array of strings and append them onto an existing array without nesting. The nesting is making it impossible for me to export . . .

댓글 수: 2

James Tursa
James Tursa 2013년 4월 25일
Typo in your posted code? The first iteration has ct = 0, which would result in tableName{0} = etc, which should have resulted in an error.
Steve
Steve 2013년 4월 26일
Fixed the typo. It was actually increased earlier on in the code. I just wanted to show it was defined and not complicate the whole thing with 30 lines of code . . .

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

 채택된 답변

Steve
Steve 2013년 4월 26일

0 개 추천

tableName (ct) = name3d(i)
Use () instead of {}. This adds each instance on one at a time rather than as one array nested inside the other.
Solved.

추가 답변 (2개)

Sean de Wolski
Sean de Wolski 2013년 4월 25일

0 개 추천

What's wrong with:
tableName = name3d
? It looks like it's already the desired result.
Steve
Steve 2013년 4월 26일

0 개 추천

I can't do that because name3d is being appended onto tableName and there may be instances where there is data already stored in the array that I don't want to lose.

카테고리

도움말 센터File Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

질문:

2013년 4월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by