필터 지우기
필터 지우기

How to copy elements of one field of structure into another new field of another structure?

조회 수: 3 (최근 30일)
Hello,
I have two structures, A and B.
B.data is 5X1 with each row length being 1x5.
B.data : 1x5
1x5
1x5
1x5
1x5
In structure A, I want to create a new field "data" and store the elements of B.data in one cell i.e.
A.data = 1x25.
I think it should be easy, but I am not able to copy it in this pattern. Can any one help me out with the solution.
Thanks in advance.

답변 (1개)

Ankita Nargundkar
Ankita Nargundkar 2017년 6월 22일
A.data = cell2mat(arrayfun(@(x) x.data,B,'Uni',false))
should do the trick. Also refer to these docs for more info. cell2mat and arrayfun

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by