|
"Christian " <vlad.impotech@gmx.net> wrote in message <hej5dt$ela$1@fred.mathworks.com>...
> Hello,
> I am still very new to Matlab and I'm having a little problem.
> I have a large Matrix and I want to add a column that is the reciprocal of another column I already have.
>
> For example, I create a Matrix A: [3; 2; 1]
> Then I want to create a second column which has the reciprocal of those values.
>
> I tried:
>
> A(:,2) = 1/A(:,1)
>
> but that results in a seceond column of [0.33333 , 0 , 0]', so obviously something went wrong here.
> The line A(1:3,2) = 1/A(1:3,2) gives the same result.
>
> So I guess my question really is, what syntax do I have to use so that the correct value gets calculated in every row, because obviously the way I tried it doesn't work.
>
> Sorry if this question seems pretty dumb, I couldnt really find the answer in the Matlab help and it would be really nice if you could clear this up for me or point me in the right direction.
>
> Thanks,
> Christian
Hi Christian, you should read about Matlab's . operator, is this context, you can see
>>help rdivide
A= [3; 2; 1];
A(:,2) = 1./A(:,1);
Hope that helps,
Wayne
|