# When using solve to <return> a single variable

#### hhtt

##### Senior Member
Hi, Because I am a student, it is important to understand textbooks for me. So I want to ask you a question about the verb of return in this example sentence: "When using solve to return a single variable, the array syntax is not necessary." The source is the book Matlab Demystified. Can someone explain me please what does it mean by
"to return a single variable" and here "solve" is a command.

Best Regards.

• #### entangledbank

##### Senior Member
A function returns a value. If sqr() calculates squares, and you put 8 in, the function call sqr(8) returns the value 64 - you give it the value 8, and it then gives you the value 64, which is called the return value. A function that solves an equation might need to return one value or more than one. So x - 2 = 0 has only one answer, but (x - 2)(x + 3) = 0 has two answers, and a cubic has three answers, and so on. So in general the solve() function needs to return an array of values: such as [2, -3] or [2, -3, -7]. But if it returns only one value (a single variable), it doesn't have to return the one-value array . It can just return the one variable value 2. The value 2 is just a number, but the array  uses array syntax.

#### hhtt

##### Senior Member
But here the usage is a little different. Can you explain it? "MATLAB will simply return the command prompt and won’t say anything else,but if you try to use these variables again without assigning them values it will be as if they had not been seen before." So what does it mean
by return the command prompt.

Last edited:

#### Andygc

##### Senior Member
Are you sure you copied that correctly? Not "MATLAB will simply return to the command prompt ..." A mathematical function cannot return the command prompt, the prompt isn't a value.

#### Myridon

##### Senior Member
In command line mode, you are given a command prompt:
>
you type
> sqr(8)
and Matlab returns:
64
>
It "returns" the result and puts up a new command prompt. In this case, you type some gibberish and it give you no answer but it does give you a command prompt.
You type:
> gibberish
MATLAB returns:
>

#### hhtt

##### Senior Member
In command line mode, you are given a command prompt:
>
you type
> sqr(8)
and Matlab returns:
64
>
It "returns" the result and puts up a new command prompt. In this case, you type some gibberish and it give you no answer but it does give you a command prompt.
You type:
> gibberish
MATLAB returns:
>
Hi, Myridon. What do you mean by gibberish? If I write it(gibberish) to the command prompt Matlab do not recognize it. Can you expand that example please. And thank you
for Matlab course.

#### Andygc

##### Senior Member
Context would help. We don't know what comes before "MATLAB will simply return the command prompt and won’t say anything else,but if you try to use these variables again without assigning them values it will be as if they had not been seen before."

#### Judica

##### Senior Member
Hi, Myridon. What do you mean by gibberish? If I write it(gibberish) to the command prompt Matlab do not recognize it. Can you expand that example please. And thank you
for Matlab course.
"Gibberish" means anything that makes no sense. (see a dictionary)

MATLAB takes mathematical values, if you put in "tank", a word, you will get a command prompt because there is no mathematical value for MATLAB to compute.

Myridon's explanation is spot on.

#### hhtt

##### Senior Member
Namely, If we write some gibberish things on matlab command prompt it returns them to command prompt. Is it true?

#### Andygc

##### Senior Member
Myridon's explanation is spot on.
As an explanation of what happens, but not of the phrase "return the command prompt". MATLAB may well return a null value following an input error (which won't, of course, display on the screen), but it can't return the prompt. It returns to the command prompt after every transaction, whatever value it returns, but that is a different meaning of 'return' from the original question about 'return a variable'. Remember this is supposed to be a discussion of the meaning and use of words, not of a computer program.

#### Myridon

##### Senior Member
You didn't give us enough context to really answer the question. I mean "whatever action that the book is talking about before the sentence you gave in post #3". I was just making an guess that it might be typing something that the program doesn't understand.

#### Andygc

##### Senior Member
You didn't give us enough context to really answer the question. Spot on there, too. Come on, hhtt, please provide proper context before you add more questions.

#### hhtt

##### Senior Member
< Previous | Next >