Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

New to MATLAB?

Thread Subject:
How to get the elements of a 1x1 cell

Subject: How to get the elements of a 1x1 cell

From: Bruce Heu

Date: 6 Apr, 2011 02:38:04

Message: 1 of 1

I used textscan to read a composite txt file with multple lines with mixed numbers and strings. The command I used is a=textscan(fid,%s,'delimiter','\t'). I use size(a) I get ans=1. If display a, there will be a multiple lines. Using cellfun(@length,a), I got the number of lines.

My question is, how can I get the element of the cell out using index such as a{1},...,a{n}, which actually is the string of each line? When use a{1}, it display the entire file. Using a(2), it says "Index exceeds matrix dimensions" sinc the dimension of the cell is 1x1. But cellfun(@length,a) returns the number of lines.

What is the difference between the value for the length from cellfun(@length,a) and that from size(a)?

Thank you...

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us