How do I name individual cells from a cell

조회 수: 1 (최근 30일)
fernando aguirre
fernando aguirre 2018년 5월 30일
댓글: fernando aguirre 2018년 5월 31일
I'm creating a .mat file with some parameters (angle = array and transmission = cell 1x9 with 12000x20 individual cells). How do I name and save each 12000x20 cell with the name "generic" + individual component of the array "angle". Note that cells in "transmission" were calculated based off the order of angle, so order should already be matched up. Necessary for calculations based off another function.
  댓글 수: 4
Stephen23
Stephen23 2018년 5월 31일
"How do I name and save each 12000x20 cell with the name "generic" + individual component of the array "angle""
Don't do this. Using indexing is much simpler, most efficient, and easier to debug.
"Note that cells in "transmission" were calculated based off the order of angle, so order should already be matched up"
That is exactly what indexing does: keeps things in a particular order. So easy with indexing!
fernando aguirre
fernando aguirre 2018년 5월 31일
Thank you, I'll look into indexing.

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

채택된 답변

Jan
Jan 2018년 5월 30일
편집: Jan 2018년 5월 30일
A bold guess: You want to use a struct?
Note that creating 12000x20 different variables or fields of a struct would be extremely inefficient and very ugly. You would have to hide an index in the names of the fields, and this is a bad idea. See Tutorial: Avoid the dynamic creation of variables.
  댓글 수: 3
Jan
Jan 2018년 5월 30일
I assume, that using an array is much more efficient and cleaner, than a huge struct with magically numbered field names. I simply refuse to post code to produce 240'000 field names, although this is very easy using sprintf and "dynamic fieldnames" (use these terms to search in the forum). I'm too convinced, that this method will be a shot in your knee and I'm not willing to hut you.
I suggest to explain the actual problem with more details to get a better strategy than a huge struct array. Currently the explanations of what you want to do are not clear enough to be understood.
fernando aguirre
fernando aguirre 2018년 5월 31일
It's really only 20 field names, but fair enough. Thank you for your help!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by