How to create multiple structure variables and assign values to them at one line.
조회 수: 4 (최근 30일)
이전 댓글 표시
I want to create a structure type for example 'AC' and assign values to its fields all at one line as follows:
[AC.a, AC.b] = [5, 15]
댓글 수: 0
답변 (2개)
Dyuman Joshi
2023년 3월 16일
편집: Dyuman Joshi
2023년 3월 16일
%Assign any type of data to a field
[AC.a, AC.b, AC.c, AC.d] = deal(5, 15, {'cell'}, '0');
AC
댓글 수: 0
Voss
2023년 3월 16일
One way:
[AC.a, AC.b] = deal(5, 15);
AC
Another way:
C = {5, 15};
[AC.a, AC.b] = C{:};
AC
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 String Parsing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!