How to access nested cell data?

2 次查看(过去 30 天)
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