FAQ  •  Login

Matlab HW#4

<<

ME451Vaidyanathan

ME451 Student
ME451 Student

Posts: 8

Joined: Thu Oct 28, 2010 11:49 am

Unread post Sat Nov 13, 2010 8:39 am

Matlab HW#4

Hello Prof. Dan

1. What should be the initial position, orientation & velocity of bodies 1 & 2 (Example 3.1.2) for Matlab Hw#4?

General question (not related to this HW):
2. Also, I am not sure as how C1 & C2 are defined for Absolute distance constraints (according to the language developed in Matlab HW#3) - Is it xPground and yPground?

Thanks & Regards
Vaidy
<<

Dan Negrut

Global Moderator
Global Moderator

Posts: 833

Joined: Wed Sep 03, 2008 12:24 pm

Unread post Sat Nov 13, 2010 8:47 am

Re: Matlab HW#4

ME451Vaidyanathan wrote:Hello Prof. Dan

1. What should be the initial position, orientation & velocity of bodies 1 & 2 (Example 3.1.2) for Matlab Hw#4?

General question (not related to this HW):
2. Also, I am not sure as how C1 & C2 are defined for Absolute distance constraints (according to the language developed in Matlab HW#3) - Is it xPground and yPground?

Thanks & Regards
Vaidy


Question 1: the motion dictates the initial conditions (think about it a minute).

Question 2: at this point, it doesn't matter, either way is good.  You the master of your simEngine2D: whatever way you choose to decide understand its consequences and use the definition consistently.

i hope this answers your questions.
Dan
<<

Wa'el

ME451 Student
ME451 Student

Posts: 7

Joined: Thu Oct 28, 2010 11:46 am

Location: Mifflin

Unread post Thu Nov 18, 2010 11:38 am

Re: Matlab HW#4

My code is working but its way too slow ... Anybody has the same issue?
ps: I'm not using any symbolic differentiation ... but I am using the subs function.

Thanks!
Bob Dylan is God
<<

ME451Vaidyanathan

ME451 Student
ME451 Student

Posts: 8

Joined: Thu Oct 28, 2010 11:49 am

Unread post Fri Nov 19, 2010 3:08 am

Re: Matlab HW#4

Yes, I also face the same problem.. In my case it is slow because of two reasons:
1. am doing object oriented programming (in matlab)
2. because am using "cell arrays" to achieve polymorphism (which I intend to replace with matlab's polymorphism - but am not sure if matlab supports it..)

I timed my simulation and it took 2.5 minutes to do a 10 second simulation (0.001 s time step) for a 2 body model (slider crank)
<<

Dan Negrut

Global Moderator
Global Moderator

Posts: 833

Joined: Wed Sep 03, 2008 12:24 pm

Unread post Fri Nov 19, 2010 7:50 am

Re: Matlab HW#4

Wa'el wrote:
My code is working but its way too slow ... Anybody has the same issue?
ps: I'm not using any symbolic differentiation ... but I am using the subs function.

Thanks!



Wa'el - please post here how you use the subs function.  I'm curious how it compares to what i posted in a previous discussion on handling these symbolic functions.

Secondly, if you really want to understand if the symbolic stuff is slowing you down, for the problem that you work with simply get rid of the symbolic stuff by actually plugging in the simple expression of the motion.  If you end up doing this, please post the CPU time before and after eliminating the symbolic component, i'm curious what impact it has, it's worth knowing...

Have a good day,
Dan
<<

Wa'el

ME451 Student
ME451 Student

Posts: 7

Joined: Thu Oct 28, 2010 11:46 am

Location: Mifflin

Unread post Fri Nov 19, 2010 1:41 pm

Re: Matlab HW#4

Dan Negrut wrote:
Wa'el wrote:
My code is working but its way too slow ... Anybody has the same issue?
ps: I'm not using any symbolic differentiation ... but I am using the subs function.

Thanks!



Wa'el - please post here how you use the subs function.  I'm curious how it compares to what i posted in a previous discussion on handling these symbolic functions.

Secondly, if you really want to understand if the symbolic stuff is slowing you down, for the problem that you work with simply get rid of the symbolic stuff by actually plugging in the simple expression of the motion.  If you end up doing this, please post the CPU time before and after eliminating the symbolic component, i'm curious what impact it has, it's worth knowing...

Have a good day,
Dan


I pretty much used the same subs function you posted in that previous discussion:

function [value,firstD,secondD] = somePhiConstraint(f,fPrime,fPrimePrime,t)
value = subs(f,t);
firstD = subs(fPrime,t);
secondD = subs(fPrimePrime,t);


However, if I change the C(t) to some higher order polynomial (say 3*t^3) such that the old approach (see code below) would work, ... the code runs in like a couple of seconds.

function [value,firstD,secondD] = somePhiConstraint(f,fPrime,fPrimePrime,t)
value = f(t);
firstD = fPrime(t);
secondD = fPrimePrime(t);


So it looks to me like the MATLAB function subs is the guy slowing things down.
Bob Dylan is God

Return to ME451 Fall 2010: Kinematics and Dynamics of Machine Systems

Who is online

Users browsing this forum: No registered users and 2 guests

cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software.