Extract data from a structure
조회 수: 198 (최근 30일)
이전 댓글 표시
I have a "1x1 struct" with 2 fields. One of the fields is data and is a 7909x10 double, while the other field is textdata that is a 1x1 cell containing the header of the output file.
I do not know how to make it so that I only have the data field that is a 7909x10 double. From there I only need columns 1,2,3 and 6 from those 10 columns and would like to delete the other 6 columns to make a new data structure.
댓글 수: 0
답변 (2개)
Ameer Hamza
2018년 4월 21일
From your questions and comments, the following solution will work for you. Suppose you original struct is A and you want to create another struct object B by deleting some columns of A and sorting rows according to column 1.
B = A; B.data = B.data(:, [1 2 3 6]); % delete columns of data [~, ind] = sort(B.data(:,1)); % get sorted indexes for column 1 B.data = B.data(ind, :); % now sort all rows of data matrix.
This will give you required struct B.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Structures에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!