필터 지우기
필터 지우기

Center of mass - Going nuts!

조회 수: 6 (최근 30일)
Rasmus
Rasmus 2013년 10월 29일
답변: sixwwwwww 2013년 10월 29일
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
sixwwwwww
sixwwwwww 2013년 10월 29일
I run you code and didn't get any error. Can you specify what error are you getting?

댓글을 달려면 로그인하십시오.

답변 (2개)

Rasmus
Rasmus 2013년 10월 29일
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 2013년 10월 29일
Dear Rasmus, I run your code and got these two values:
Xko =
2.000428632661809
Yko =
3.357265323617660
Are these values not correct?

카테고리

Help CenterFile Exchange에서 Numeric Solvers에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by