help-octave
[Top][All Lists]
Advanced

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

Re: Add row vector to column vector


From: Brett Green
Subject: Re: Add row vector to column vector
Date: Wed, 27 Nov 2019 10:58:46 -0500


On Wed, Nov 27, 2019 at 10:43 AM Jonathan Seidel <address@hidden> wrote:
Hello,
I am starting to learn octave. However I stumbled across the following:

I defined a as a row-vector and b as a column vector. Then I added a + b and expected some sort of error message, because the vectors down have the same format. However, I received the following answer. Why ?

>> a = [1 2 3]; b = [1; 2; 3];
>> a + b
ans =

   2   3   4
   3   4   5
   4   5   6

Thanks in advance for your help.
Greetings,
Jonathan

Octave "fills in the gaps" and adds
1 2 3
1 2 3
1 2 3
to
1 1 1
2 2 2
3 3 3
giving you the result above. Perhaps someone else who's been a user longer than I have can explain the motivation for having Octave process the input this way rather than giving an error.

reply via email to

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