help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: input a string


From: Isak Delberth Davids
Subject: Re: input a string
Date: Mon, 22 Nov 2010 14:44:15 +0200

On 22 November 2010 14:38, Andy Buckle <address@hidden> wrote:
On Mon, Nov 22, 2010 at 12:32 PM, Isak Delberth Davids
<address@hidden> wrote:
> Hi all,
>
> I would like to put a character string into title plots. I managed by doing
>
> clear;clc;
> x = -30:30;
> y = sin(x);
> WhatItIs = 'sine curve'; % this is  OK
> plot(x,y)
> title(sprintf('This is my %s',WhatItIs),'FontSize',14,'FontWeight','bold');
>
> I was happy, but wanted to be a bit fancy --- I want the user to input the
> string at run time, so I did:
>
> clear;clc;
> x = -30:30;
> y = sin(x);
> WhatItIs = input('Please tell us what this is  '); % this fails
> plot(x,y)
> title(sprintf('This is my %s',WhatItIs),'FontSize',14,'FontWeight','bold');
>
> How should I write the line that request user input of a string?

I took a look at "help input". I think this should do the trick.

WhatItIs = input('Please tell us what this is  ','s')

--
/* andy buckle */

Great! Thanks Andy --- I see, I should have added the argument 's' that says that the just inputted animal is a literal string value. Appreciated!

Isak

--
* * * * * * * * * * * * * * *
*  Isak Delbert Davids *
*  +264-81-33 049 33  *
*  +264-61-206 3789   *
*    Namibia, Afrika     *
* * * * * * * * * * * * * * *


reply via email to

[Prev in Thread] Current Thread [Next in Thread]