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

Thread Subject:
cell to double problem

Subject: cell to double problem

From: Bilal

Date: 4 Oct, 2010 15:06:05

Message: 1 of 8

Hi,

I am reading a file and putting different columns into different variables. The problem is, some columns are labeled as "cell" while others are "double". i need to plot these variables and Matlab doesnt let me plot the "cell" variables. I'm using the code below to assign variables to the respective columns:

    L1_ST = data{6};
    L2_ST = data{7};
    L1_Upper = data{8};
    L1_Lower = data{9};
    L2_Upper = data{10};
    L2_Lower = data{11}; --> these are all curly brackets

L1_ST and L2_ST are the only ones that are read as double, while the rest are cell. How is it that 2 columns are read as double, while the others are read as cell when i'm using the same code for all? What am i doing wrong?

Subject: cell to double problem

From: dpb

Date: 4 Oct, 2010 15:08:15

Message: 2 of 8

Bilal wrote:
> Hi,
>
> I am reading a file and putting different columns into different
> variables. The problem is, some columns are labeled as "cell" while
> others are "double". i need to plot these variables and Matlab doesnt
> let me plot the "cell" variables. I'm using the code below to assign
> variables to the respective columns:
>
> L1_ST = data{6};
> L2_ST = data{7};
> L1_Upper = data{8};
> L1_Lower = data{9};
> L2_Upper = data{10};
> L2_Lower = data{11}; --> these are all curly brackets
>
> L1_ST and L2_ST are the only ones that are read as double, while the
> rest are cell. How is it that 2 columns are read as double, while the
> others are read as cell when i'm using the same code for all? What am i
> doing wrong?

Don't show how data() was created so don't know what the contents of
cells 8-11 are. One presumes there's a reason... :)

--

Subject: cell to double problem

From: Bilal

Date: 4 Oct, 2010 15:13:05

Message: 3 of 8

"Bilal " <bilalhaider87@gmail.com> wrote in message <i8cqgt$8ic$1@fred.mathworks.com>...
> Hi,
>
> I am reading a file and putting different columns into different variables. The problem is, some columns are labeled as "cell" while others are "double". i need to plot these variables and Matlab doesnt let me plot the "cell" variables. I'm using the code below to assign variables to the respective columns:
>
> L1_ST = data{6};
> L2_ST = data{7};
> L1_Upper = data{8};
> L1_Lower = data{9};
> L2_Upper = data{10};
> L2_Lower = data{11}; --> these are all curly brackets
>
> L1_ST and L2_ST are the only ones that are read as double, while the rest are cell. How is it that 2 columns are read as double, while the others are read as cell when i'm using the same code for all? What am i doing wrong?


NEVERMIND!! i found out my mistake.

Subject: cell to double problem

From: Bilal

Date: 4 Oct, 2010 15:15:23

Message: 4 of 8

"Bilal " <bilalhaider87@gmail.com> wrote in message <i8cqgt$8ic$1@fred.mathworks.com>...
> Hi,
>
> I am reading a file and putting different columns into different variables. The problem is, some columns are labeled as "cell" while others are "double". i need to plot these variables and Matlab doesnt let me plot the "cell" variables. I'm using the code below to assign variables to the respective columns:
>
> L1_ST = data{6};
> L2_ST = data{7};
> L1_Upper = data{8};
> L1_Lower = data{9};
> L2_Upper = data{10};
> L2_Lower = data{11}; --> these are all curly brackets
>
> L1_ST and L2_ST are the only ones that are read as double, while the rest are cell. How is it that 2 columns are read as double, while the others are read as cell when i'm using the same code for all? What am i doing wrong?


NEVERMIND!!! i found my mistake. Although, i could do with some help with plotting. i want to plot L1_ST, L1_Upper and L1_Lower on one plot. How can i accomplish this without having one overwrite the other?

Subject: cell to double problem

From: Sean

Date: 4 Oct, 2010 15:15:23

Message: 5 of 8

"Bilal " <bilalhaider87@gmail.com> wrote in message <i8cqgt$8ic$1@fred.mathworks.com>...
> Hi,
>
> I am reading a file and putting different columns into different variables. The problem is, some columns are labeled as "cell" while others are "double". i need to plot these variables and Matlab doesnt let me plot the "cell" variables. I'm using the code below to assign variables to the respective columns:
>
> L1_ST = data{6};
> L2_ST = data{7};
> L1_Upper = data{8};
> L1_Lower = data{9};
> L2_Upper = data{10};
> L2_Lower = data{11}; --> these are all curly brackets
>
> L1_ST and L2_ST are the only ones that are read as double, while the rest are cell. How is it that 2 columns are read as double, while the others are read as cell when i'm using the same code for all? What am i doing wrong?

Use cellfun() to remove the inner cells. I believe you'd have to show us what data is to answer your other question.

Subject: cell to double problem

From: Bilal

Date: 4 Oct, 2010 15:38:04

Message: 6 of 8

dpb <none@non.net> wrote in message <i8cqsr$kiu$1@news.eternal-september.org>...
> Bilal wrote:
> > Hi,
> >
> > I am reading a file and putting different columns into different
> > variables. The problem is, some columns are labeled as "cell" while
> > others are "double". i need to plot these variables and Matlab doesnt
> > let me plot the "cell" variables. I'm using the code below to assign
> > variables to the respective columns:
> >
> > L1_ST = data{6};
> > L2_ST = data{7};
> > L1_Upper = data{8};
> > L1_Lower = data{9};
> > L2_Upper = data{10};
> > L2_Lower = data{11}; --> these are all curly brackets
> >
> > L1_ST and L2_ST are the only ones that are read as double, while the
> > rest are cell. How is it that 2 columns are read as double, while the
> > others are read as cell when i'm using the same code for all? What am i
> > doing wrong?
>
> Don't show how data() was created so don't know what the contents of
> cells 8-11 are. One presumes there's a reason... :)
>
> --

Lol good point...one would assume such things but truth be told, i completely forgot to show you guys that part. i didnt know what code i would need to show to get my question answerd...dumb of me.

data = textscan(fid2, '%s %s %s %s %s %f %f %f %f %f %f');

That's what i use to read the data. once 6-11 are read, i want to plot them but how can i get three sets of data on one plot (6, 8, 9 and 7, 10, 11)? (i hope i'm not missing other necessary code)

Subject: cell to double problem

From: dpb

Date: 4 Oct, 2010 22:34:11

Message: 7 of 8

Bilal wrote:
,,,

> NEVERMIND!!! i found my mistake. Although, i could do with some help
> with plotting. i want to plot L1_ST, L1_Upper and L1_Lower on one plot.
> How can i accomplish this without having one overwrite the other?

hold on

doc hold

Alternatively,

doc plotyy

--

Subject: cell to double problem

From: dpb

Date: 4 Oct, 2010 22:37:55

Message: 8 of 8

dpb wrote:
> Bilal wrote:
> ,,,
>
>> NEVERMIND!!! i found my mistake. Although, i could do with some help
>> with plotting. i want to plot L1_ST, L1_Upper and L1_Lower on one
>> plot. How can i accomplish this without having one overwrite the other?
>
> hold on
...

Oh, also, put them in an array and plot() will do it automagically for
you...

doc plot

--

Tags for this Thread

No tags are associated with 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