From: Peter on
I bet this is so simple - but I'm new to Matlab. I have tried to guess from other matrix manipulation and can't find it in the help.

I create an x,y matrix and now I want to divide the last column (col 4) by a number - but only the last column.

Here's what I added to my function to make this happen:

y(:,4)=y(:,4)./(215.^2); % reduce solar radiation to TOA
plot(w,y);

So I am trying to divide col 4 of this array by 215^2.
But it doesn't.

For ref, the whole function (can be better setup as others have recently explained):

====testb.m=======
function y = testb(x)
% x is the array of numbers to use
% ..
w=(0.02:0.02:100)'; % wavelength from 0.02um to 100um
for i=1:numel(x)
y(:,i)= planck(w,x(i));
end
y(:,4)=y(:,4)./(215.^2); % reduce solar radiation to TOA
plot(w,y);
end
=============

Appreciate any help.
Thanks
From: John D'Errico on
"Peter " <pgillies3(a)gmail.com> wrote in message <i2gu1e$e8g$1(a)fred.mathworks.com>...
> I bet this is so simple - but I'm new to Matlab. I have tried to guess from other matrix manipulation and can't find it in the help.
>
> I create an x,y matrix and now I want to divide the last column (col 4) by a number - but only the last column.
>
> Here's what I added to my function to make this happen:
>
> y(:,4)=y(:,4)./(215.^2); % reduce solar radiation to TOA
> plot(w,y);
>
> So I am trying to divide col 4 of this array by 215^2.
> But it doesn't.

So please tell us why do you think that it does not do what
you want?

It does. You found the correct way to solve your problem.

John
From: Peter on
>
> So please tell us why do you think that it does not do what
> you want?
>
> It does. You found the correct way to solve your problem.
>
> John


Thanks very much John. You are right - before it was not working and now it is. I don't understand, perhaps I ran the wrong function..

Appreciate the help.