Help with erase()

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Help with erase()

Rik-4
Could someone try the following code in Matlab?

s = erase('this is it',['this';'is'])
double (s)

Thanks,
Rik

Reply | Threaded
Open this post in threaded view
|

Re: Help with erase()

bredsj

Matlab R2017b Ubuntu 16.04 LTS

>> untitled
Error using untitled (line 1)
Dimensions of matrices being concatenated are not consistent.


On 26/12/2017 07:39, Rik wrote:
Could someone try the following code in Matlab?

s = erase('this is it',['this';'is'])
double (s)

Thanks,
Rik


--
Steph
Steph Bredenhann
Reply | Threaded
Open this post in threaded view
|

Re: Help with erase()

bredsj
In reply to this post by Rik-4

A better answer, using quotes

clear all

s = erase("this is it",["this";"is"])
double (s)

>> untitled2

s =

    "  it"


ans =

   NaN


On 26/12/2017 07:39, Rik wrote:
Could someone try the following code in Matlab?

s = erase('this is it',['this';'is'])
double (s)

Thanks,
Rik


--
Steph Bredenhann Pr.Eng, Pr.CPM

Tel: 021 854 6927
Fax: 086 66 95 380
Mobile: 082 55 00 207

(sent from PC)
Steph Bredenhann
Reply | Threaded
Open this post in threaded view
|

Re: Help with erase()

bredsj
In reply to this post by Rik-4

A better answer, using quotes

clear all

s = erase("this is it",["this";"is"])
double (s)

>> untitled2

s =

    "  it"


ans =

   NaN


On 26/12/2017 07:39, Rik wrote:
Could someone try the following code in Matlab?

s = erase('this is it',['this';'is'])
double (s)

Thanks,
Rik


--
Steph
Steph Bredenhann
Reply | Threaded
Open this post in threaded view
|

Re: Help with erase()

Carnë Draug
On 26 December 2017 at 08:08, Steph Bredenhann <[hidden email]> wrote:

> A better answer, using quotes
>
> clear all
>
> s = erase("this is it",["this";"is"])
> double (s)
>
>>> untitled2
>
> s =
>
>     "  it"
>
>
> ans =
>
>    NaN

Can you try double quotes on the second argument but not on the
first. The reason why double(s) returns NaN is that it's a Matlab
string and not a char array.

  s = erase ('this is it', ["this"; "is"])
  double (s)

or

  s = erase ('this is it', {'this'; 'is})
  double (s)

Thank you
Carnë

Reply | Threaded
Open this post in threaded view
|

Re: Help with erase()

Rik-4
In reply to this post by Rik-4
On 12/26/2017 02:33 AM, [hidden email] wrote:
> Subject: > Re: Help with erase() > From: > Steph Bredenhann [hidden email] > Date: > 12/25/2017 11:10 PM > To: > [hidden email] > List-Post: > [hidden email] > Precedence: > list > MIME-Version: > 1.0 > References: > <MTAwMDAxMC5ub21hZA.1514266795@quikprotect> > In-Reply-To: > <MTAwMDAxMC5ub21hZA.1514266795@quikprotect> > Message-ID: > [hidden email] > Content-Type: > multipart/alternative; boundary="------------392867A0F0A911AE0620A8D6" > Message: > 5 > > Matlab R2017b Ubuntu 16.04 LTS > > >> untitled > Error using untitled (line 1) > Dimensions of matrices being concatenated are not consistent. > > On 26/12/2017 07:39, Rik wrote: >> Could someone try the following code in Matlab? >> >> s = erase('this is it',['this';'is']) >> double (s)
Okay, I thought Matlab could at least handle concatenation.  Try this instead

s = erase ('this is it', ['this';'is  '])
double (s)

I don't want double quotes because I'm trying to check if character arrays are supported and double quotes will create string arrays which are an entirely different data type.

Cheers,
Rik


Reply | Threaded
Open this post in threaded view
|

Re: Help with erase()

bredsj

Hi Rik

Result is

>> untitled3
Error using erase (line 44)
Text to replace must be a string array, character vector, or cell array of character vectors.

Error in untitled3 (line 3)
s = erase ('this is it', ['this';'is  '])
 


On 26/12/2017 18:32, Rik wrote:
s = erase ('this is it', ['this';'is  '])
double (s)

--
Steph
Steph Bredenhann
Reply | Threaded
Open this post in threaded view
|

Re: Help with erase()

bredsj
In reply to this post by Carnë Draug

Carne

The result is

>> untitled3

s =

    '  it'


ans =

    32    32   105   116


On 26/12/2017 12:33, Carnë Draug wrote:
s = erase ('this is it', ["this"; "is"])
  double (s)

--
Steph
Steph Bredenhann