create matrix : (1:3)(1:5)

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

create matrix : (1:3)(1:5)

turbofib
hi
i want to create this matrix:

a=1  1  1  1  1
    2  2  2  2  2
    3  3  3  3  3




--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: create matrix : (1:3)(1:5)

marco atzeri-2
Am 24.10.2018 um 11:41 schrieb turbofib:
> hi
> i want to create this matrix:
>
> a=1  1  1  1  1
>      2  2  2  2  2
>      3  3  3  3  3
>
>
and what is your problem ?

https://octave.org/doc/interpreter/Simple-Examples.html#Creating-a-Matrix



---
Diese E-Mail wurde von Avast Antivirus-Software auf Viren gepr├╝ft.
https://www.avast.com/antivirus



Reply | Threaded
Open this post in threaded view
|

Re: create matrix : (1:3)(1:5)

Michele Ginesi
In reply to this post by turbofib

On 10/24/18 11:41 AM, turbofib wrote:

> hi
> i want to create this matrix:
>
> a=1  1  1  1  1
>      2  2  2  2  2
>      3  3  3  3  3
>
>
>
>
> --
> Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html
>
>

Hi,
you can do as follows:
        a = repmat([1,2,3]',1,5)
or, using broadcasting,
        a = ones(1,5) + [0,1,2]'

--
Michele Ginesi



Reply | Threaded
Open this post in threaded view
|

Re: create matrix : (1:3)(1:5)

turbofib
thank you michele

use to  repmat is correct !



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html