1. PF Contest - Win "Conquering the Physics GRE" book! Click Here to Enter
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Matlab, adding columns in matrices

  1. Jan 27, 2010 #1
    1. The problem statement, all variables and given/known data

    I need to create a function for scilab which adds a row of zeros to the right of an nxn matrix, a.
    I also have to add a row of 6's at the bottom but I think i have that part down.

    2. Relevant equations

    I think ones(,) is supposed to help?

    3. The attempt at a solution

    I have tried to use ones...

    function m_1=matrix_1(a,n)

    I figure if [a;ones(1,n)] gives 1 row and n columns (at the bottom), then [a,ones(n;1)] should make n rows and 1 column. Instead I have an error 'waiting for right parenthesis.'

    I have also thought of zeros but I don't know how to add n rows of zeros since you must type [0;0;0....] for each row.
  2. jcsd
  3. Jan 27, 2010 #2
    Sorry, I realize there is a math & science software forum.
  4. Jan 31, 2010 #3
    u should do
    m= [a zeros(1,size(m,2))];
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Similar Threads - Matlab adding columns Date
GR conditions conserved quantities AdS s-t; t-l geodesic May 21, 2017
Rewriting ODE's into lower orders Nov 15, 2016
Matrix riccati differential equation using matlab Aug 5, 2016
Convolution in MATLAB Sep 28, 2015
Matlab help Jul 12, 2015