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:
structures, cell arrays, and assigning 'NaN'

Subject: structures, cell arrays, and assigning 'NaN'

From: Notsure USA

Date: 3 Mar, 2011 21:14:21

Message: 1 of 3

Say I have a struct of cells containing arrays:

Struct.element1 = [x y z];
Struct.element2 = [m n p];
… and so on

So if I want to access the first element of the array contained in element1 of the struct, I say

Struct.element1(1)

Or if I want to assign it a value, I can say

Struct.element1(1) = 0;

Why can't I do this:

Struct.element1(1) = ‘NaN’;

???

Subject: structures, cell arrays, and assigning 'NaN'

From: Sean de

Date: 3 Mar, 2011 21:21:08

Message: 2 of 3

"Notsure USA" wrote in message <ikp0bd$2i3$1@fred.mathworks.com>...

> Why can't I do this:
>
> Struct.element1(1) = ‘NaN’;
>
> ???

Because 'Nan' is a 1x3 string and thus can't fit in a 1x1 spot. You want Nan (no single quotes).

Subject: structures, cell arrays, and assigning 'NaN'

From: Notsure USA

Date: 3 Mar, 2011 21:36:20

Message: 3 of 3

"Sean de " <sean.dewolski@nospamplease.umit.maine.edu> wrote in message <ikp0o4$rod$1@fred.mathworks.com>...
> "Notsure USA" wrote in message <ikp0bd$2i3$1@fred.mathworks.com>...
>
> > Why can't I do this:
> >
> > Struct.element1(1) = ‘NaN’;
> >
> > ???
>
> Because 'Nan' is a 1x3 string and thus can't fit in a 1x1 spot. You want Nan (no single quotes).

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