Shortcut to making an array

조회 수: 9 (최근 30일)
Sarah Abdullah
Sarah Abdullah 2020년 4월 3일
댓글: Stephen23 2020년 4월 3일
Hi,
I have 41 variable named b1 through 41 (ex. b1 b2 b3 b4...), I'm trying to combine all these varibale into one array. But I want to see if there is a shortcut to do so.
I know I can do K= [b1 b2 ... b41], but I'm wondering if there is a shortcut to that.
Thank you
  댓글 수: 1
Stephen23
Stephen23 2020년 4월 3일
Numbered variables are a sign that you are doing something wrong.
Most likely those names were generated in a loop or when importing data (unless you sat there and wrote out all of those names), in which case that is the correct place to fix your code. For example, rather than load-ing directly into the workspace, load into an output variable (which is a scalar structure) and then access it from that variable:
S = load(...)

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

답변 (1개)

Walter Roberson
Walter Roberson 2020년 4월 3일
The shortcut is to not create those as separate variables the first time around.

카테고리

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

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by