Q:

Write a script that creates a vector of line segments (where each is a nested structure as shown in this chapter). Initialize the vector using any method. Print a table showing the values, such as shown in the following:

0

Write a script that creates a vector of line segments (where each is a nested structure as shown in this chapter). Initialize the vector using any method. Print a table showing the values, such as shown in the following:

 Line From To

==== ======= =======

 1 ( 3, 5) ( 4, 7)

 2 ( 5, 6) ( 2, 10)

etc.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Ch8Ex24.m

% Create a vector of line segments and

% print a table showing the values

fprintf('Line From\t\tTo\n')

fprintf('==== =======\t=======\n')

for i = 1:10 % 10 segments

 linestr(i).from.x = randint(1,1,[-10,10]);

 linestr(i).from.y = randint(1,1,[-10,10]);

 linestr(i).to.x = randint(1,1,[-10,10]);

 linestr(i).to.y = randint(1,1,[-10,10]);

 fprintf(' %d ( %d, %d)\t( %d, %d)\n',...

 i,linestr(i).from.x, linestr(i).from.y,...

 linestr(i).to.x, linestr(i).to.y)

end

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now