Center of mass - Going nuts!

1 visualización (últimos 30 días)
Rasmus
Rasmus el 29 de Oct. de 2013
Respondida: sixwwwwww el 29 de Oct. de 2013
Hello We are given a task, where we have to calculate the center of mass of an area given by 3 functions. We have to do it numerical using symbolic toolbox.
My problem is how to calculate it using a vectors and sum function. I have found the mass and the x-coordinate, but the y-coordinate are giving me trouble. My code is like this:
syms x
f1(x)=3-x;
f2(x)=x-1;
f3(x)=-x^2+4*x-1;
m=1; x1plot = 1:0.001:2; x2plot = 2:0.001:3;
M1=m*(sum(f3(x1plot))-sum(f1(x1plot)))*0.001; M2=m*(sum(f3(x2plot))-sum(f2(x2plot)))*0.001; M=M1+M2;
'The mass' vpa(M)
Xko=sum((1/M)*m*x1plot.*((f3(x1plot)-f3(x2plot))+(f1(x1plot)+f2(x2plot)))*0.001)
'x koor'
vpa(Xko)
Yk2=(f1(x1plot)-f2(x2plot)+(f3(x1plot)+f3(x2plot)))/2
Yko=sum((1/M)*m*((f3(x1plot)-f3(x2plot))+(f1(x1plot)+f2(x2plot))).*Yk2*0.001)
'Y koor' vpa(Yko)
I hope that you are able to see my problem and hopefully give me an answer. Thank you!
  1 comentario
sixwwwwww
sixwwwwww el 29 de Oct. de 2013
I run you code and didn't get any error. Can you specify what error are you getting?

Iniciar sesión para comentar.

Respuestas (2)

Rasmus
Rasmus el 29 de Oct. de 2013
No particullar errors, but i now from mupad, that the value has to be around 2.08 and not 3.3 so i now something isn't correct.

sixwwwwww
sixwwwwww el 29 de Oct. de 2013
Dear Rasmus, I run your code and got these two values:
Xko =
2.000428632661809
Yko =
3.357265323617660
Are these values not correct?

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by