Here is the assignment to graph on matlab.. Need to figure out the codes that wi
ID: 1813801 • Letter: H
Question
Here is the assignment to graph on matlab.. Need to figure out the codes that will looks like the graph on the picture.
Here is how far I have gone.. and got stuck.. Please help me..
Thank you
xcoords=[1 7 6 8 3 5 9 2 8 6 2 4 1];
ycoords=[8 3 7 5 9 1 3 6 8 8 2 3 4];
masses=[11 8 10 4 5 11 6 7 12 8 9 6 5];
xlabel('x-axis')
ylabel('y-axis')
title('center of mass')
xcenter=(mean(masses)*mean(xcoords))/mean(masses);
ycenter=(mean(masses)*mean(ycoords))/mean(masses);
hold on
plot(xcenter, ycenter, 'g--+')
hold off
line([xcenter xcoords(1)],[ycenter ycoords(1)])
line([xcenter xcoords(2)],[ycenter ycoords(2)])
line([xcenter xcoords(3)],[ycenter ycoords(3)])
line([xcenter xcoords(4)],[ycenter ycoords(4)])
line([xcenter xcoords(5)],[ycenter ycoords(5)])
line([xcenter xcoords(6)],[ycenter ycoords(6)])
line([xcenter xcoords(7)],[ycenter ycoords(7)])
line([xcenter xcoords(8)],[ycenter ycoords(8)])
line([xcenter xcoords(9)],[ycenter ycoords(9)])
line([xcenter xcoords(10)],[ycenter ycoords(10)])
line([xcenter xcoords(11)],[ycenter ycoords(11)])
line([xcenter xcoords(12)],[ycenter ycoords(12)])
line([xcenter xcoords(13)],[ycenter ycoords(13)])
BUT NEED TO USE DISP COMMAND TO SHOW THE GRAPH.. and can't figure it out..
% coardinate and masses of particles x coards = [1 7 6 8 3 5 9 2 8 6 2 4 1]; ycoards = [8 3 7 5 9 1 3 6 8 8 2 3 4 ]; masses = [11 8 10 4 5 11 6 7 12 8 9 6 5]; % caliculate the center of mass of the particle x center = y center = % print center of mass coardinates using dispExplanation / Answer
xcoords=[1 7 6 8 3 5 9 2 8 6 2 4 1];
ycoords=[8 3 7 5 9 1 3 6 8 8 2 3 4];
masses=[11 8 10 4 5 11 6 7 12 8 9 6 5];
xlabel('x-axis')
ylabel('y-axis')
title('center of mass')
xcenter=(mean(masses)*mean(xcoords))/mean(masses);
ycenter=(mean(masses)*mean(ycoords))/mean(masses);
hold on
plot(xcenter, ycenter, 'g--+')
hold off
line([xcenter xcoords(1)],[ycenter ycoords(1)])
line([xcenter xcoords(2)],[ycenter ycoords(2)])
line([xcenter xcoords(3)],[ycenter ycoords(3)])
line([xcenter xcoords(4)],[ycenter ycoords(4)])
line([xcenter xcoords(5)],[ycenter ycoords(5)])
line([xcenter xcoords(6)],[ycenter ycoords(6)])
line([xcenter xcoords(7)],[ycenter ycoords(7)])
line([xcenter xcoords(8)],[ycenter ycoords(8)])
line([xcenter xcoords(9)],[ycenter ycoords(9)])
line([xcenter xcoords(10)],[ycenter ycoords(10)])
line([xcenter xcoords(11)],[ycenter ycoords(11)])
line([xcenter xcoords(12)],[ycenter ycoords(12)])
line([xcenter xcoords(13)],[ycenter ycoords(13)])
x = [xcenter ycenter];
disp(x)