フィルターのクリア

How to access nested cell data?

2 ビュー (過去 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 Center および File ExchangeCell Arrays についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by