From: Jan Simon on
Dear Philosophaie,

> ra(1900)=2
> ra(1950)=3
> ra(1990)=4
> ra(2000)=5
> ra(2050)=8
>
> hold on;
> for k=1900:10:2050
> if ra(k)<>0
> plot(k,ra(k))
> end
> end

As far as I understand, you want something like this:
t = [1900, 1950, 1990, 2000, 2050];
y = [2, 3, 4, 5, 8];
plot(t, y);
Or if it is really needed to create the large vector ra:
ra(1900)=2
ra(1950)=3
ra(1990)=4
ra(2000)=5
ra(2050)=8
index = (ra ~= 0);
t = 0:2050
plot(t(index), ra(index))

Good luck, Jan
From: Walter Roberson on
Philosophaie wrote:
> Walter Roberson <roberson(a)hushmail.com> wrote in message
> <CLM5o.15950$mW5.11932(a)newsfe14.iad>...
>> Philosophaie wrote:
>>
>> > if ra(k)<>0
>>
>> if ra(k) ~= 0
>
> This works great.
> I am having a little trouble getting the dots to connect with lines. I
> put '-b' after the plot(k, ra(k), '-b'). There should be blue line
> connecting the points so I can run a "Data Fitting" in the graph section
> and get a linear or polynomial approximation.

You are not plotting a line in that statement: you are plotting a single
point.

I see that another poster showed how to convert this into a matrix
operation that would plot all at one time. The solution from the other
poster would implicitly join together adjacent non-zero ra's, which is
fine if that is what you want, but do you happen to instead want each
zero ra to end the current line segment?