Matlab, adding columns in matrices

slugbunny
Messages
13
Reaction score
0

Homework Statement



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.

Homework Equations



I think ones(,) is supposed to help?

The Attempt at a Solution



I have tried to use ones...

function m_1=matrix_1(a,n)
m_1=[a,0*(ones(n;1))]
endfunction

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.
 
Physics news on Phys.org
Sorry, I realize there is a math & science software forum.
 
u should do
m= [a zeros(1,size(m,2))];
 
There are two things I don't understand about this problem. First, when finding the nth root of a number, there should in theory be n solutions. However, the formula produces n+1 roots. Here is how. The first root is simply ##\left(r\right)^{\left(\frac{1}{n}\right)}##. Then you multiply this first root by n additional expressions given by the formula, as you go through k=0,1,...n-1. So you end up with n+1 roots, which cannot be correct. Let me illustrate what I mean. For this...
Back
Top