필터 지우기
필터 지우기

Preallocate memory for the rows of each field inside a structure

조회 수: 1 (최근 30일)
L_Del
L_Del 2019년 7월 2일
편집: Stephen23 2019년 7월 2일
Hi all
This should be pretty easy but I can't seem to find the right way to do this...
I have this structure, each of its fields are preallocated so field 1 = [ ], same for the rest. I'm filling the rows of each field one at a time so Matlab is complaining that I should preallocate the rows first. I tried nameofstructure(1:900).field1=[ ] but this doesn't work. I've also tried with the curly brackets with no avail.
What's the correct way to preallocate the rows once the fields have been preallocated? Thanks!
LD

답변 (1개)

Stephen23
Stephen23 2019년 7월 2일
편집: Stephen23 2019년 7월 2일
This should get you started:
>> S = struct('F',{[],[],[]});
>> S.F
ans =
[]
ans =
[]
ans =
[]
>> [S.F] = deal(zeros(3,5));
>> S.F
ans =
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
ans =
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
ans =
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
See:

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by