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:
Matlab, convert char 2 double

Subject: Matlab, convert char 2 double

From: cristiano

Date: 18 May, 2009 03:08:28

Message: 1 of 3

Hi,

I have

x = 2;

class x returns char

I want x as a double, in the way that class x will return double.

In other words, I want to convert from char to double.

I tried x=double(x) and x = str2num(x), but this two do not work.

Subject: Matlab, convert char 2 double

From: Nasser Abbasi

Date: 18 May, 2009 03:22:20

Message: 2 of 3


"cristiano" <cstrieder@gmail.com> wrote in message
news:9106086.114380.1242616139412.JavaMail.jakarta@nitrogen.mathforum.org...
> Hi,
>
> I have
>
> x = 2;
>
> class x returns char
>
> I want x as a double, in the way that class x will return double.
>
> In other words, I want to convert from char to double.
>
> I tried x=double(x) and x = str2num(x), but this two do not work.

EDU>> clear all
EDU>> x='2'

x =

2

EDU>> class x

ans =

char

EDU>> x=str2num(x)

x =

     2

EDU>> class(x)

ans =

double


--Nasser

Subject: Matlab, convert char 2 double

From: Daniel Armyr

Date: 18 May, 2009 06:18:01

Message: 3 of 3

> class x returns char
Yeah, it does, because what you just wrote translates in matlab to:
> class 'x' which is a character string.

What you want to write is
>class ( x )

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