How to access nested cell data?

조회 수: 1 (최근 30일)
SUSHMA MB
SUSHMA MB 2015년 4월 23일
댓글: SUSHMA MB 2015년 4월 23일
I am attaching the file which contains the coordinates of a polygon. I want to split the data given in the attached file into x and y variables. For example:
x=[1,1,2,2,1,NaN,4,4,5,5,4,NaN,6,6,7] and
y=[1,1,2,2,1,NaN,4,4,5,5,4,NaN,6,6,7]
How can i split my data into this format. Please do answer my question. Thank you

채택된 답변

Guillaume
Guillaume 2015년 4월 23일
편집: Guillaume 2015년 4월 23일
it's very unclear what you're asking particularly as there's no value in your demo matrix that belongs to the set [1,1,2,2,1,NaN,4,4,5,5,4,NaN,6,6,7].
In view that your cell array contains exclusively, N x 2 matrices, I'll assume that you just want to concatenate the whole lot. Use vertcat together with expension of cell array into comma separated lists:
load('trialdataofcoordinates.mat');
coords = vertcat(mycoordinates{:});
x = coords(:, 1)
y = coords(:, 2)
  댓글 수: 3
Guillaume
Guillaume 2015년 4월 23일
The simplest way is to add a row of 1x2 matrices of NaN to your cell array. The reshaping into a single column (with the : operation) will automatically place the NaN matrix in between each other matrices:
load('trialdataofcoordinates.mat');
mycoordinates(2, :) = {[nan nan]};
coords = vertcat(mycoordinates{:});
x = coords(:, 1)
y = coords(:, 2)
SUSHMA MB
SUSHMA MB 2015년 4월 23일
Thank you so much. Its really very helpful........Thank you once again

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

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by