Thread Subject: Plotting - Not all of them are plotted

Subject: Plotting - Not all of them are plotted

From: Khanjan

Date: 22 Mar, 2010 04:00:19

Message: 1 of 2

Hi,

I am trying to plot a series of randomly generated line segments. However for some weird reason the following code is not plotting all of them. For example, if I were to set the num variable to 3, it only shows either 1 or 2 lines. If i set it to 6, it only displays 4 lines... I'm lost!! If you need more parts of my code please let me know. Thanks.

for i = 1:num
    if (i == 1)
        axis([0 film_length 0 film_length]);
        hold all;
    end
    X{i} = originX(i,1):0.1:endX(i,1);
    Y{i} = slope(i,1) * X{i} + intercept(i,1);
    p = plot(X{i},Y{i});
    if (typeset(i,1) == 3)
        set(p,'Color','green');
    else
        set(p,'Color','red');
    end
end

Subject: Plotting - Not all of them are plotted

From: Walter Roberson

Date: 22 Mar, 2010 04:36:45

Message: 2 of 2

Khanjan wrote:

> I am trying to plot a series of randomly generated line segments.
> However for some weird reason the following code is not plotting all of
> them. For example, if I were to set the num variable to 3, it only shows
> either 1 or 2 lines. If i set it to 6, it only displays 4 lines... I'm
> lost!! If you need more parts of my code please let me know. Thanks.
>
> for i = 1:num
> if (i == 1)
> axis([0 film_length 0 film_length]);
> hold all;
> end
> X{i} = originX(i,1):0.1:endX(i,1); Y{i} = slope(i,1) * X{i} +
> intercept(i,1);

If originX(i,1) is less than endX(i,1) then X{i} would be an empty
vector and no line would be drawn.

xstart = min(originX(i,1),endX(i,1));
xend = max(originX(i,1),endX(i,1));
X{i} = xstart:0.1:xend

> p = plot(X{i},Y{i});
> if (typeset(i,1) == 3)
> set(p,'Color','green');
> else
> set(p,'Color','red');
> end
> end

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Contact us at files@mathworks.com