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:
belongs to book: MATLAB: A Practical Introduction to Programming and Problem Solving|Stormy Attaway|Fourth Edition| Chapter number:8| Question number:24.8
All Answers
total answers (1)
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