How to index a cell with two columns?

조회 수: 5 (최근 30일)
Lei
Lei 2012년 4월 30일
Hello, everyone. I have a cell which looks like this:
775.446000000000 774.706000000000
774.706000000000 773.246000000000
773.246000000000 772.906000000000
772.906000000000 770.906000000000
770.906000000000 770.116000000000
Is there a way to extract data or index from this cell to get a result like the below one?
775.446000000000
774.706000000000
773.246000000000
772.906000000000
770.906000000000
770.116000000000
Basically,I want get all of the data from the first column and last one from second column since the other data are repeated which are useless for me. Anybody would like to help me out...thanks a lot!

채택된 답변

Richard Brown
Richard Brown 2012년 4월 30일
[data(:, 1); data(end,2)]
  댓글 수: 3
Richard Brown
Richard Brown 2012년 4월 30일
A cell array is pretty much like a regular array, except that the contents are "cells" rather than numbers. So you can manipulate them the same way as with regular arrays.
You only use the cell indexing {} when you want to get at what is inside the cells.
So what I did was to vertically concatenate the first column (data(:, 1)) with the last entry of the second column (data(end,2)). This is exactly the same command as I'd use if your data was just in a regular matrix.
Lei
Lei 2012년 5월 1일
yeah,that make sense.I know how to index cell arrays,I just never used the 'end' before and did not think to put them in a single matrix. Thanks again for your help! This really helps me!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by