Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
set of points to a line

Subject: set of points to a line

From: Angelo

Date: 28 Sep, 2010 17:31:39

Message: 1 of 4

hi, i have this code:

for x = 20:100
   for y= 50
      image(x,y) = 0;
   end
end

how can i save the set of points created by the nested for loop to a line?

Subject: set of points to a line

From: Sean

Date: 28 Sep, 2010 18:09:04

Message: 2 of 4

"Angelo " <kuyagerms_07@yahoo.com> wrote in message <i7t8pr$69e$1@fred.mathworks.com>...
> hi, i have this code:
>
> for x = 20:100
> for y= 50
> image(x,y) = 0;
> end
> end
>
> how can i save the set of points created by the nested for loop to a line?

You have no reason to have an inner for loop seeing as how it never changes.
The above code could be converted to:

[xx yy] = meshgrid(20:100,50);
image(sub2ind(size(image),xx,yy)) = 0;

Then xx, yy are the lines you want I presume.

Subject: set of points to a line

From: Ross W

Date: 28 Sep, 2010 18:54:04

Message: 3 of 4

"Sean " <sean.dewolski@nospamplease.umit.maine.edu> wrote in message <i7tb00$1mh$1@fred.mathworks.com>...
> "Angelo " <kuyagerms_07@yahoo.com> wrote in message <i7t8pr$69e$1@fred.mathworks.com>...
> > hi, i have this code:
> >
> > for x = 20:100
> > for y= 50
> > image(x,y) = 0;
> > end
> > end
> >
> > how can i save the set of points created by the nested for loop to a line?
>
> You have no reason to have an inner for loop seeing as how it never changes.
> The above code could be converted to:
>
> [xx yy] = meshgrid(20:100,50);
> image(sub2ind(size(image),xx,yy)) = 0;
>
> Then xx, yy are the lines you want I presume.

Note that image is the name of a built-in Matlab command, so it's risky to use this name for a variable.

Ross

Subject: set of points to a line

From: Angelo

Date: 28 Sep, 2010 18:56:21

Message: 4 of 4

"Sean " <sean.dewolski@nospamplease.umit.maine.edu> wrote in message <i7tb00$1mh$1@fred.mathworks.com>...
> "Angelo " <kuyagerms_07@yahoo.com> wrote in message <i7t8pr$69e$1@fred.mathworks.com>...
> > hi, i have this code:
> >
> > for x = 20:100
> > for y= 50
> > image(x,y) = 0;
> > end
> > end
> >
> > how can i save the set of points created by the nested for loop to a line?
>
> You have no reason to have an inner for loop seeing as how it never changes.
> The above code could be converted to:
>
> [xx yy] = meshgrid(20:100,50);
> image(sub2ind(size(image),xx,yy)) = 0;
>
> Then xx, yy are the lines you want I presume.


Thanks so much for the help! :D

Tags for this Thread

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.

Contact us