Borrar filtros
Borrar filtros

How to access nested cell data?

2 visualizaciones (últimos 30 días)
SUSHMA MB
SUSHMA MB el 23 de Abr. de 2015
Comentada: SUSHMA MB el 23 de Abr. de 2015
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

Respuesta aceptada

Guillaume
Guillaume el 23 de Abr. de 2015
Editada: Guillaume el 23 de Abr. de 2015
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 comentarios
Guillaume
Guillaume el 23 de Abr. de 2015
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 el 23 de Abr. de 2015
Thank you so much. Its really very helpful........Thank you once again

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Cell Arrays en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by